A powerful, easy-to-use API for generating PDF documents from HTML content or URLs.
Generate PDFs from URLs or HTML content
Merge multiple PDFs into one (including the one you generated from HTML)
Powered by Puppeteer and headless Chromium
Serverless deployment ready
Open source
Customizable page settings (soon, open to contribution)
This hosted API is provided for demonstration purposes only. Please deploy it on your own infrastructure, or I'll have to shut it down.
You can deploy it freely to Vercel with one click.
To generate a PDF, you can make a JSON POST request to the /api/gen
endpoint with either a url
or html
parameter in the request body. You can also merge multiple PDFs by passing an array of PDF URLs in the merge
parameter. The merged PDF will be returned as a single document.
curl -X POST 'https://pdf.mathieutu.dev/api/gen' \
--header 'Content-Type: application/json' \
--output 'foo.pdf' \
--data-raw '{
"filename": "foo.pdf",
"html": "<html><head><script src=\"https:\/\/cdn.tailwindcss.com\"><\/script><\/head><body class=\"h-screen grid place-items-center\"><span class=\"print:hidden\">IT SHOULD NO BE PRINTED<\/span><div class=\"bg-pink-300 text-pink-800 p-8 h-[100px] grid place-items-center font-medium font-mono\">@mathieutu<\/div><\/body><\/html>",
"merge": [
"https://pour-un-reveil-ecologique.org/documents/54/10_key_points_IPCC_1_2_and_3.pdf"
]
}'
You can also directly pass a url in query parameter of a GET request: https://pdf.mathieutu.dev/api/gen?url=https://pdf.mathieutu.dev&merge=https://pour-un-reveil-ecologique.org/documents/54/10_key_points_IPCC_1_2_and_3.pdf
The response will be a PDF document with the appropriate content type headers.
This project was created by @mathieutu, a passionate developer focused on building open-source tools and APIs.
Feel free to contribute to the project or reach out for collaboration opportunities.