fbpx
印刷

JavaからBuildVuを実行する

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ページを参照してください。

ハイブリッド版:

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ページを参照してください。
SVGコンテンツを使用する場合は、PDFtoSVGConverterを参照下さい。

設定方法

利用可能な設定とその値はJavadocにあります。 主要なクラスは次のとおりです:

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

BuildVuの主な機能はPDFファイルをHTML5に変換することですが、OfficeドキュメントをHTML5に変換するには、LibreOfficeを使用してオフィスドキュメントをPDFに変換しておくこともできます。

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フォントをインストールすることをおすすめします。

    MENU
    PAGE TOP