How to Save a PDF as HTML Programmatically Using Acrobat JavaScript
Question details
Developers need a method to convert PDF files into HTML format using an API or programmatic workflow in Adobe Acrobat.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Automating the conversion of PDF files to HTML documents via scripting or external calls like VBA.
- Observed behavior
- Developers want to achieve the same HTML conversion capability available in the Acrobat UI through programmable JavaScript methods.
Ensure you have Adobe Acrobat Pro installed, as standard Reader does not support document conversion via the saveAs method. You must also verify that HTML conversion support is fully available in your Acrobat environment.
Using the Acrobat JavaScript saveAs Method
Utilize the built-in saveAs method in Acrobat JavaScript with the HTML conversion ID to automate the export process.
Acrobat provides a powerful JavaScript API that allows developers to automate tasks, including document format conversion. By specifying the correct conversion ID, you can programmatically instruct Acrobat to output an HTML file.
This JavaScript method can be executed directly within the Acrobat console or triggered via external automation interfaces, such as Excel VBA.
Open Adobe Acrobat Pro and access the JavaScript Debugger console, or prepare your external script (e.g., VBA) to call the Acrobat application's JSObject.
Run the following code to convert the active document: this.saveAs({cPath: this.path.replace('.pdf', '.html'), cConvID: 'com.adobe.acrobat.html'});
Navigate to the destination folder (by default, the same directory as the original PDF) to confirm the new HTML file has been generated successfully.

Convert PDFs to HTML Effortlessly Using WPS Office
If you want to avoid writing complex JavaScript code, WPS Office offers a built-in, user-friendly tool to convert PDF documents to HTML format instantly while preserving the original layout and elements.
- 1. Open your PDF in WPS: Launch WPS Office and open the PDF file you wish to convert.
- 2. Navigate to the conversion tools: Click on the 'Tools' tab in the top ribbon and select the 'PDF to HTML' or equivalent export option.
- 3. Configure conversion settings: Set your desired output folder and check any specific page ranges you wish to extract.
- 4. Export the HTML file: Click 'Convert' to generate the HTML file immediately and securely on your local device.

Frequently Asked Questions
Can I run Acrobat JavaScript from VBA to convert PDFs?
Yes, you can invoke Acrobat JavaScript using the Acrobat OLE automation objects in VBA. By calling the JSObject, you can execute the saveAs method with the HTML conversion ID directly from an Excel or Word macro.
Why is my PDF to HTML conversion script failing in Acrobat?
The conversion can fail if you are using Adobe Reader instead of Acrobat Pro, or if the specific HTML conversion plugin or export support is missing or disabled in your installation environment.
What is the exact conversion ID for exporting PDF to HTML in Acrobat?
The specific conversion ID required for the saveAs method to output an HTML file is 'com.adobe.acrobat.html'. Passing an incorrect ID will result in an export failure.




