Class PDFtoHTML5Converter
Examples
The following set of examples demonstrates some of the most common uses of PDFtoHTML5Converter
Conversion with IDRViewer (BuildVu Only)
This example includes a fully-featured HTML5 document viewer the converted PDF file is displayed within. This mode is recommended for users who would like a configurable viewer solution with minimal setup.
HTMLConversionOptions conversionOptions = new HTMLConversionOptions();//Set conversion options here
IDRViewerOptions viewerOptions = new IDRViewerOptions();//Set viewer options here
File pdfFile = new File("C:/MyDocument.pdf");
File outputDir = new File("C:/MyOutputDirectory/");
//Alternative constructor exists for converting from byte array
PDFtoHTML5Converter converter = new PDFtoHTML5Converter(pdfFile, outputDir, conversionOptions, viewerOptions);
try {
converter.convert();
} catch (PdfException e) {
e.printStackTrace();
}
Conversion With No Viewer (BuildVu Only)
This example converts PDF files in a simple way that allows the output to be built upon, for example for to build a custom viewer solution around the content or to use within a CMS/ERP system. Also included in the output is a properties.json file that includes information that could help build your viewing solution such as the page count, page bounds, title/author (if set), as well as any bookmarks the PDF file contains.
HTMLConversionOptions conversionOptions = new HTMLConversionOptions();//Set conversion options here
ContentOptions contentOptions = new ContentOptions();//Set content options here
File pdfFile = new File("C:/MyDocument.pdf");
File outputDir = new File("C:/MyOutputDirectory/");
//Alternative constructor exists for converting from byte array
PDFtoHTML5Converter converter = new PDFtoHTML5Converter(pdfFile, outputDir, conversionOptions, contentOptions);
try {
converter.convert();
} catch (PdfException e) {
e.printStackTrace();
}
Examples
The following set of examples demonstrates some of the most common uses of PDFFormtoHTML5Converter
Conversion With Forms Viewer (FormVu Only)
This example converts PDF Forms using our fully featured forms viewer
HTMLConversionOptions conversionOptions = new HTMLConversionOptions();//Set conversion options here
FormViewerOptions formViewerOptions = new FormViewerOptions();//Set viewer options here
File pdfFile = new File("C:/MyDocument.pdf");
File outputDir = new File("C:/MyOutputDirectory/");
//Alternative constructor exists for converting from byte array
PDFtoHTML5Converter converter = new PDFtoHTML5Converter(pdfFile, outputDir, conversionOptions, formViewerOptions);
try {
converter.convert();
} catch (PdfException e) {
e.printStackTrace();
}
-
Constructor Summary
ConstructorsConstructorDescriptionPDFtoHTML5Converter(byte[] pdfFileAsBytes, File outputDirectory, HTMLConversionOptions htmlConversionOptions, OutputModeOptions outputModeOptions) Constructs a new PDFtoHTML5Converter.PDFtoHTML5Converter(File pdfFile, File outputDirectory, HTMLConversionOptions htmlConversionOptions, OutputModeOptions outputModeOptions) Constructs a new PDFtoHTML5Converter.PDFtoHTML5Converter(InputStream pdfFile, File outputDirectory, HTMLConversionOptions htmlConversionOptions, OutputModeOptions outputModeOptions) Constructs a new PDFtoHTML5Converter. -
Method Summary
Modifier and TypeMethodDescriptionvoidconvert()Start converting the PDF file.voidsetCustomErrorTracker(ErrorTracker customErrorTracker) Sets a customErrorTrackerto use during conversion allowing you to track errors and provide a timeout.voidsetCustomIO(CustomIO customIO) Sets aCustomIOto use during conversion, allowing you to control the output.voidEnables encryption of all temporary files that may be created during the conversion process.voidsetPassword(String password) Set the password to be used to open the PDF file (if set).
-
Constructor Details
-
PDFtoHTML5Converter
public PDFtoHTML5Converter(byte[] pdfFileAsBytes, File outputDirectory, HTMLConversionOptions htmlConversionOptions, OutputModeOptions outputModeOptions) Constructs a new PDFtoHTML5Converter. Call convert() to convert the PDF.- Parameters:
pdfFileAsBytes- The PDF file you wish to convert in a byte[] array.outputDirectory- The directory you would like the converted PDF output to.htmlConversionOptions- TheHTMLConversionOptionsobject containing the settings to use in the conversion.outputModeOptions- TheOutputModeOptionsobject containing the output mode settings to use in the conversion.
-
PDFtoHTML5Converter
public PDFtoHTML5Converter(File pdfFile, File outputDirectory, HTMLConversionOptions htmlConversionOptions, OutputModeOptions outputModeOptions) Constructs a new PDFtoHTML5Converter. Call convert() to convert the PDF.- Parameters:
pdfFile- The PDF file you wish to convert.outputDirectory- The directory you would like the converted PDF output to.htmlConversionOptions- TheHTMLConversionOptionsobject containing the settings to use in the conversion.outputModeOptions- TheOutputModeOptionsobject containing the output mode settings to use in the conversion.
-
PDFtoHTML5Converter
public PDFtoHTML5Converter(InputStream pdfFile, File outputDirectory, HTMLConversionOptions htmlConversionOptions, OutputModeOptions outputModeOptions) Constructs a new PDFtoHTML5Converter. Call convert() to convert the PDF.- Parameters:
pdfFile- The PDF file you wish to convert in an InputStream.outputDirectory- The directory you would like the converted PDF output to.htmlConversionOptions- TheHTMLConversionOptionsobject containing the settings to use in the conversion.outputModeOptions- TheOutputModeOptionsobject containing the output mode settings to use in the conversion.
-
-
Method Details
-
convert
Start converting the PDF file.- Overrides:
convertin classorg.jpedal.examples.BaseConverter- Throws:
PdfException- When the PDF is corrupt, the password is incorrect, or a JVM option used an unknown value.
-
setCustomErrorTracker
Sets a customErrorTrackerto use during conversion allowing you to track errors and provide a timeout.ExampleOutputErrorTracker.java is provided as an example implementation.
- Overrides:
setCustomErrorTrackerin classorg.jpedal.examples.BaseConverter- Parameters:
customErrorTracker- TheErrorTrackerto use during conversion.
-
setCustomIO
Sets aCustomIOto use during conversion, allowing you to control the output.DefaultIO.java is provided as an example implementation.
- Overrides:
setCustomIOin classorg.jpedal.examples.BaseConverter- Parameters:
customIO- TheCustomIOto use during conversion.
-
setPassword
Set the password to be used to open the PDF file (if set).The password is set in PDF creation.
- Overrides:
setPasswordin classorg.jpedal.examples.BaseConverter- Parameters:
password- The password of the PDF file if it has one.
-
setEncryptTempFiles
public void setEncryptTempFiles()Enables encryption of all temporary files that may be created during the conversion process.Can also be enabled by using the JVM flag -Dorg.jpedal.pdf2html.encryptTempFiles=true
- Overrides:
setEncryptTempFilesin classorg.jpedal.examples.BaseConverter
-