Q: Is it possible with jPDFWeb to convert a whole PDF document to single HTML output file?

A: Yes, Qoppa’s Java PDF library, jPDFWeb, can export each page of a PDF document as an SVG element. It is then simple to add HTML header and tags around all the SVG elements to make it a single HTML page. see sample code below.

public static void  main (String [] args)
            PDFWeb pdfWeb = new PDFWeb("C:\\mydoc.pdf", null);
            // create a writer for the output file
            File outputFile = new File("mydoc.html");
            PrintWriter outWriter = new PrintWriter(outputFile, "UTF-8");
            writeHTML(pdfWeb, outWriter);
            System.out.println("Done! Look at file " + outputFile.getAbsolutePath());
        catch (Throwable t)

where writeHTML is the following method:

// Write pages as HTML
public static void writeHTML(PDFWeb pdfweb, PrintWriter outWriter) throws PDFException, IOException
// write HTML page header
outWriter.println(  "<!DOCTYPE html>\n"
+ "<!-- Created by Qoppa Software's jPDFWeb (http://www.qoppa.com) -->\n"
+ "<html>\n"
+ "	<head>\n"
+ "		<meta name=\"generator\" content=\"jPDFWeb : Java PDF to HTML5 Conversion\">\n"
+ "		<meta name=\"author\" content=\"Qoppa Software\">\n"
+ "		<meta name=\"website\" content=\"http://www.qoppa.com\">\n"
+ "		<meta charset=\"utf-8\">\n"
+ "		<style type=\"text/css\">\n"
+ "			body {background-color:lightgray; text-align:center;}\n"
+ "			.pageRect {fill:white;}\n"
+ "			#topSvg {padding:5px; margin:auto;}\n"
+ "		</style>\n"
+ "	</head>\n"
+ "	<body>");
// Convert pages
for(int i = 0; i < pdfweb.getPageCount(); i++)
 pdfweb.savePageAsSVG(i, outWriter);
// End HTML page

Try jPDFWeb Live Demo


Choose the option “View Whole Doc as HTML”.
You can upload your own PDF document and see how our PDF library convert your PDFs!