https://github.com/mathieutu/pdf-gen
Generate a pdf from html content.
https://github.com/mathieutu/pdf-gen
Last synced: about 1 year ago
JSON representation
Generate a pdf from html content.
- Host: GitHub
- URL: https://github.com/mathieutu/pdf-gen
- Owner: mathieutu
- Created: 2025-04-13T12:33:34.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-13T12:50:48.000Z (about 1 year ago)
- Last Synced: 2025-04-13T13:36:35.673Z (about 1 year ago)
- Language: TypeScript
- Homepage: https://pdf-gen-murex.vercel.app
- Size: 76.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PDF Generator
A simple API to generate PDFs from URLs or HTML content, powered by Puppeteer and headless Chromium. This project is open-source and serverless deployment ready.
## Features
- ✅ 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 (coming soon, open to contributions)
## Get Started
You can try it out on https://pdf.mathieutu.dev.
This URL is provided for demonstration purposes only.
Please deploy it on your own infrastructure, or I'll have to shut it down.
You can do it freely on Vercel [with one click](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fmathieutu%2Fpdf-gen).
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.
```bash
curl -X POST 'https://your-deployment-url/api/gen' \
--header 'Content-Type: application/json' \
--output 'foo.pdf' \
--data-raw '{
"filename": "foo.pdf",
"html": "<\/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",
]
}'
```
Alternatively, you can directly pass a URL as a query parameter in a GET request:
```bash
https://your-deployment-url/api/gen?url=https://example.com&merge=https://example.com/another.pdf&merge=https://example.com/yet-another.pdf
```
The response will be a PDF document with the appropriate content type headers.
## The Author
This project was created by [@mathieutu](https://mathieutu.dev), a passionate developer focused on building open-source tools and APIs.
Feel free to contribute to the project or [reach out](mailto:contact@mathieutu.dev) for collaboration opportunities.