HTML to PDF API using Serverless
Api2Pdf’s HTML to PDF API runs on Google Cloud Run and supports the generation of PDFs with raw HTML using two PDF engines: wkhtmltopdf and Headless Chrome. These two PDF engines are open source and each have their advantages and disadvantages. Depending on your use-case and HTML, you may find that one endpoint renders your HTML better than the other. We recommend you test both out to see which one works better for you.
Create an account and check out our documentation to get started for free.
We also offer client libraries in popular languages:
Otherwise, you can write very simple code against the REST API. Below is a simple HTML to PDF example using Python.
#python example
import requests
import json
api_key = 'your-api-key'
endpoint = 'https://v2.api2pdf.com/chrome/pdf/html'
html_to_convert = '<p>Hello World</p>'
api_response = requests.post(endpoint, json={'html': html_to_convert}, headers={'Authorization': api_key})
print(json.loads(api_response.content)['FileUrl'])
HTML to PDF conversion on Cloud Run offers some huge benefits. First, we do not have any rate limits, unlike other services out there. Hit the API as many times as you wish. And second, the cost to service the API is substantially less, resulting in much lower fees than competing services.
Our API is also available as a standalone docker container that you can run in your own cloud environment. Contact us if you are interested in learning more.
Advanced Options:
Both wkhtmltopdf and Headless Chrome have advanced options that allow you to specify margins, page layouts, and a host of other capabilities. We let you pass those options along.