A standalone, fast, and portable HTML to PDF generator. Use it in any of your project. Just pass the HTML string, and you'll get a PDF as a result.
- Standalone - It can run separately from your main applications, regardless which language or framework you use.
- Easy to use - Just send a HTTP POST request from your client, application, or server.
- High availabilty - Using puppeteer-cluster, the puppeteer instances can be restarted in case of crash
- Container support - Deploy and scale easily
Install using your favorite package manager:
pnpm install
npm install
yarn install
Run it:
pnpm run start
npm start
yarn start
Send a HTTP POST request with the body:
{
"content": "<h1>Your content here</h1>",
"options": {
"format": "A4",
"margin": {
"top": 10,
"left": 10
}
}
}
Key | Type | Description |
---|---|---|
content |
string (required) | Any HTML string will do. Most of the time, you'll get the PDF exactly as you see in your browser. You can use css class and styles in it. |
options |
Puppeteer.PDFOptions (optional) | You can pass the options to configure the Puppeteer page |
Key | Description |
---|---|
CONCURRENCY |
puppeteer-cluster concurrency options -> 1:PAGE, 2:CONTEXT, 3:BROWSER. Default: 2 |
MAX_CONCURRENCY |
Max concurrency number. (Max number of tabs/pages). Default: 5 |
You can configure and build your own image, or run it directly:
docker run -p 3000:3000 farhansyah/html-to-pdf