A powerful, easy-to-use API for generating PDF documents from HTML content or URLs.
Generate PDFs from URLs or HTML content
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:
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>"
}'
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
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.