Skip to content

Instantly share code, notes, and snippets.

@XinyuIDR
Created November 27, 2024 11:56
Show Gist options
  • Save XinyuIDR/3dd02a9cdf5a77222e96b4a3349a0ede to your computer and use it in GitHub Desktop.
Save XinyuIDR/3dd02a9cdf5a77222e96b4a3349a0ede to your computer and use it in GitHub Desktop.
Convert PDF to HTML in Java | PDF to HTML Java | PDF to HTML
/*
Download the BuildVu trial jar (https://www.idrsolutions.com/buildvu/trial-download)
Add the BuildVu Jar to your project libraries
Choose conversion options (https://files.idrsolutions.com/maven/site/buildvu/apidocs/org/jpedal/render/output/ConversionOptions.html)
Choose viewer options (https://files.idrsolutions.com/maven/site/buildvu/apidocs/org/jpedal/render/output/IDRViewerOptions.html)
Set PDF file path and output directory
*/
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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment