Blog
Test your HTML locally first
Published Oct 29, 2023
If you’re having trouble with the PDF rendered by API2PDF, here’s a simple way to troubleshoot your HTML locally using Google Chrome:
- Copy the HTML you’re sending to API2PDF and paste it into a plain text editor like Notepad.
- Save the file with a
.html
extension (for example,test.html
). - Open
test.html
in Google Chrome. This will display the file as a web page, letting you see exactly how it will render. - To preview it as a PDF, right-click on the page, select Print, and choose Save as PDF in the destination options.
This process lets you spot any issues with the layout, styling, or content in Chrome before sending it to API2PDF. Adjust as needed until the local version looks as you want it to. This strategy is effective because API2PDF uses Headless Chrome to generate the PDF. It is basically the same technology.
While on the preview screen, it also lets you click More Settings. If you are sending advanced options to API2PDF, you will often find those settings available there as well.
Hope this helps.