In this article we will walk you through the best way to figure out why your HTML is not properly rendering as PDF using our API service.
Open up your favorite text editor like notepad++ or VS Code and save your raw HTML that you’ve been sending to API2PDF and save it as a .html file. After you save this .html file, open up the file in Google Chrome.
With Google Chrome and your .html file open, hit F12 key to bring up your Developer Console. Scan for any errors that might appear in this console. The most common mistake is that you are referencing assets using relative links instead of fully resolved links. For example, in your HTML you might have something like:
<img src=”/uploads/static/logo.png” />
<img src=”https://mysite.com/uploads/static/logo.png” />
Resolve all of the errors that appear in the console and then try again. If you are still experiencing problems, then your issue may be a bit more complex. Verify that the issue you are facing still occurs when you test it against the API directly using our SwaggerHub Documentation here: outlined here: https://www.api2pdf.com/
**Note** – There is a limitation in SwaggerHub that will abort your request if generating the PDF takes longer than 10 seconds. So if your PDF takes longer than 10 seconds to generate, this step will not be helpful.
If it works fine on SwaggerHub, but not from within your own code, then you know there must be a bug in your code that you have to figure out.
If you are out of ideas and need guidance from support, you can email email@example.com and please be sure to include the following information:
- Endpoints you are using (GET or POST method, wkhtmltopdf/headless chrome, url/html, merge, delete, zxing, etc).
- What language you are writing your code in. Are you using one of our client libraries or wrote your own code?
- If using URL to PDF, provide a sample URL. If you are using HTML to PDF, provide a gist.github.com or attach a .html file sample of the HTML to you are using.
- Are you using any of the advanced wkhtmltopdf or headless chrome options like header / footer, margins, page sizes, etc.?