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

JavaからBuildVuを実行する

Javaから実行する

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

前提条件:

クイックスタート:

BuildVu-SVG:

SVGConversionOptions conversionOptions = new SVGConversionOptions();
// Set conversion options here e.g. conversionOptions.setCompressImages(true);

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.setCompressImages(true);

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 のインストールをお勧めします。