Convert PDF to HTML
Overview
ComPDF Conversion SDK provides the PDF to HTML function, which can convert PDF files to HTML files while maintaining the layout and format of the original document, allowing users to browse and view the document on Web.
Notice
When converting PDF to HTML format, ComPDF Conversion SDK provides the following four options to create HTML files:
| Option | Description |
|---|---|
HtmlSinglePage | Convert the entire PDF file into a single HTML file, where all PDF pages are connected in sequence by page number, displayed on the same HTML page. |
HtmlSinglePageWithBookmark | Convert the PDF file into a single HTML file with all PDF page content on the same page in sequential order. This option also adds a bookmark navigation bar to the HTML page for quick navigation to a specific page. |
HtmlMultiPage | Convert the PDF file into multiple HTML files. Each HTML file corresponds to a PDF page, and users can navigate to the next page via a link at the bottom of the page. |
HtmlMultiPageWithBookmark | Convert the PDF file into multiple HTML files, each corresponding to a PDF page. An outline HTML page is provided for navigation, allowing users to jump to the corresponding HTML page by clicking the outline. |
Sample
This sample demonstrates how to convert from a PDF to HTML file.
go
inputFilePath := "***"
password := "***"
outputFileName := "***"
htmlOptions := compdf.NewHtmlOptions()
err := compdf.StartPDFToHtml(inputFilePath, password, outputFileName, htmlOptions, nil)