Link

Run from Java

You can run BuildVu directly from within a Java application. This guide is aimed at developers with knowledge of Java.

Prerequisites:

Quick Start:

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();
}

For more information, please see the Javadoc page for PDFtoSVGConverter.

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();
}

For more information, please see the Javadoc page for PDFtoHTML5Converter.

How are the settings controlled?

Available settings and their values can be found in the Javadoc. The key classes are:

Office Document Support:

Although BuildVu’s primary function is to convert PDF files to HTML5, it is also possible to enable conversion of Office documents to HTML5 by utilising LibreOffice to pre-convert office documents to PDF.

After you have installed LibreOffice, the DocumentToPDFConverter class can be used to invoke LibreOffice to preprocess Office documents so that you don’t have to.

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*
}

It is recommended to read the Javadoc. The source code for the DocumentToPDFConverter class is also available to view online.

If you are running LibreOffice on Linux you may find that some files do not convert correctly if they make use of fonts that are not available on Linux. We would recommend installing Google Noto Fonts to increase the likelihood that missing fonts will be substituted with a fallback.