H2P is a lightweight service designed to convert HTML content into PDF documents efficiently. It offers a straightforward API, making it ideal for applications that require dynamic PDF generation from HTML templates.
To deploy H2P using Helm, follow these steps:
Add the Helm repository:
helm repo add h2p https://dacdigital.github.io/h2p
helm repo update
Install the H2P chart:
helm install h2p h2p/h2p
This command deploys H2P into your Kubernetes cluster with default settings.
You can customize the deployment by providing your own values.yaml file or by setting parameters directly in the command line.
Once deployed, H2P exposes an endpoint to which you can POST HTML content. It responds with the corresponding PDF.
curl --location --request POST 'http://localhost:3000/print' \
--header 'Content-Type: application/json' \
--data-raw '{
"title": "ExampleRoute",
"html": "<html><body><h1>My first Heading</h1><p>My first paragraph.</p></body></html>"
}'
curl --location --request POST 'http://localhost:3000/print' \
--header 'Content-Type: application/json' \
--data-raw '{
"title": "ExampleRoute",
"html": "<html><body><h1>My first Heading</h1><p>My first paragraph.</p></body></html>",
"options":
{
"margin":
{
"top": "35px",
"right": "35px",
"left": "35px"
}
}
}'
The source code for H2P is available on GitHub.