Skip to main content
Interwork Corporation
IDR Solutions Product Support Portal
PDF開発用語集 モードの切替 ダーク/ライト/自動 モードの切替 ダーク/ライト/自動 モードの切替 ダーク/ライト/自動

JavaからBuildVuを実行する

Javaから実行する

BuildVuはJavaアプリケーションから直接実行することができます。このガイドはJavaの知識を持つ開発者を対象としています。

前提条件:

クイックスタート:

コンバーターの第4引数で出力モード を選択します: IDRViewerOptions(バンドルされたビューアー、以下で使用)、ContentOptions(生のHTML/SVGフラグメント)、または SinglefileOptions(HTMLのみ — 単一の自己完結型ファイル)。

BuildVu-SVG:

SVGConversionOptions conversionOptions = new SVGConversionOptions();
// Set conversion options here e.g. conversionOptions.setImageScale(2);

IDRViewerOptions viewerOptions = new IDRViewerOptions();
// Set viewer options here e.g. viewerOptions.setViewerUI(IDRViewerOptions.ViewerUI.Clean);

File pdfFile = new File("C:/MyDocument.pdf");
File outputDir = new File("C:/MyOutputDirectory/");

PDFtoSVGConverter converter = new PDFtoSVGConverter(pdfFile, outputDir, conversionOptions, viewerOptions);

try {
    converter.convert();
} catch (PdfException e) {
    e.printStackTrace();
}

詳細については、PDFtoSVGConverter のJavadocページをご覧ください。

BuildVu-HTML:

HTMLConversionOptions conversionOptions = new HTMLConversionOptions();
// Set conversion options here e.g. conversionOptions.setImageScale(2);

IDRViewerOptions viewerOptions = new IDRViewerOptions();
// Set viewer options here e.g. viewerOptions.setViewerUI(IDRViewerOptions.ViewerUI.Clean);

File pdfFile = new File("C:/MyDocument.pdf");
File outputDir = new File("C:/MyOutputDirectory/");

PDFtoHTML5Converter converter = new PDFtoHTML5Converter(pdfFile, outputDir, conversionOptions, viewerOptions);

try {
    converter.convert();
} catch (PdfException e) {
    e.printStackTrace();
}

詳細については、PDFtoHTML5Converter のJavadocページをご覧ください。

設定はどのように管理されますか?

利用可能な設定とその値はJavadocで確認できます。主要なクラスは以下のとおりです:

また、利用可能な設定とその値の一覧は変換オプション セクションでも確認できます。

Officeドキュメントのサポート:

BuildVuの主な機能はPDFファイルをHTML5に変換することですが、LibreOffice を利用してOfficeドキュメントをPDFに事前変換することで、OfficeドキュメントをHTML5に変換することも可能です。

LibreOfficeをインストールした後、DocumentToPDFConverter クラスを使用してLibreOfficeを呼び出し、Officeドキュメントを前処理することができます。これにより、手動での変換作業が不要になります。

if (DocumentToPDFConverter.hasConvertibleFileType(document)) {
    try {
        DocumentToPDFConverter.convert(document, libreOfficeExecutablePath);

        // Code to convert generated PDF file to HTML5 goes here

    } catch (IOException e) {
        // Problem occurred - see Javadoc for reasons
    } catch (InterruptedException e) {
        // Process was interrupted
    }
} else {
    // File type not supported*
}

Javadocを読む ことをお勧めします。DocumentToPDFConverter クラスのソースコードはオンラインで閲覧 することもできます。

LinuxでLibreOfficeを実行している場合、Linux上で利用できないフォントを使用しているファイルが正しく変換されないことがあります。不足しているフォントが代替フォントに置き換えられる可能性を高めるために、Google Noto Fonts のインストールをお勧めします。