A mini service to generate PDF from HTML, uses Handlebars for parsing the HTML, Puppeteer to run the headless browser, and NATS for handling queue.
compose directory cd compose..env.example to .env and set the variables.docker compose up --build -d./docs./pdf with method POST, for the payload described below.Commands to manage git tags for Docker image releases.
| Command | Usage | Description |
|---|---|---|
tag-delete | make tag-delete TAG=v1.0.0 | Delete tag from local and remote |
tag-push | make tag-push TAG=v1.0.0 | Create and push a new tag |
tag-repush | make tag-repush TAG=v1.0.0 | Delete existing tag and re-push (useful when a build fails) |
compose/compose.yaml file.client directory is only the example how to interact with the service.| Field | Required | Desc |
|---|---|---|
| html | Yes | The escaped HTML string for rendering. |
| header | No | The escaped HTML string for header purpose. |
| footer | No | The escaped HTML string for footer purpose. |
| margin | No | The object for setting the margin { top, right, bottom, left }. |
| alias | No | The alias for the filename. |
| values | No | The object for the data that needed by the html. |
| format | No | The format for generated PDF, should be one of "letter" | "legal" | "tabloid" | "ledger" | "a0" | "a1" | "a2" | "a3" | "a4" | "a5" | "a6", this field will take over the width and height. |
| width | No | Width of document. Ignored if format is filled. |
| height | No | Height of document. Ignored if format is filled. |
| webhookUrl | No | URL to receive the generated PDF. The service will POST a JSON body containing alias, metadata, and pdf (base64-encoded). See Webhook Payload below. |
| metadata | No | Arbitrary key-value object sent along with the webhook, so the receiver can identify/route the data (e.g. { "orderId": "123", "userId": "456" }). |
When webhookUrl is provided, the service will POST a JSON body to that URL:
{
"alias": "my-document",
"metadata": { "orderId": "123", "userId": "456" },
"pdf": "<base64-encoded PDF>"
}
| Field | Type | Description |
|---|---|---|
| alias | string | The filename alias (without .pdf extension). |
| metadata | object | The metadata object from the original request (defaults to {}). |
| string | The generated PDF file, base64-encoded. |
| Name | Arguments | Return |
|---|---|---|
| add | number, number | number |
| min | number, number | number |
| mul | number, number | number |
| div | number, number | number |
| gt | number, number | boolean |
| gte | number, number | boolean |
| lt | number, number | boolean |
| lte | number, number | boolean |
| eq | number, number | boolean |
| ne | number, number | boolean |
| or | boolean, boolean | boolean |
| and | boolean, boolean | boolean |
| not | boolean | boolean |
| contains | string, string | boolean |
| startWith | string, string | boolean |
| endWith | string, string | boolean |
| replace | string, string, string | string |
| json | object | string |
| lower | string | string |
| upper | string | string |
| isEmpty | any | boolean |
Content type
Image
Digest
sha256:e2d40a4b5…
Size
471.1 MB
Last updated
2 months ago
docker pull ariefsn/html-to-pdf