Quick Start Guide
This guide shows how to run H2P (HTML to PDF conversion service) using Docker.
Launching Using Docker Compose
1. Create compose.yaml
version: '3.8'
services:
h2p:
image: dacinfomotion/h2p:latest
container_name: h2p
ports:
- "3000:3000"
restart: unless-stopped
2. Start the service
docker-compose up -d
The service will be available at http://localhost:3000
.
3. Try it out
Send a POST request to the /print
endpoint.
curl --location --request POST 'http://localhost:3000/print' \
--header 'Content-Type: application/json' \
--output ExampleFile.pdf \
--data-raw '{
"title": "ExampleRoute",
"html": "<html><body><h1>My first Heading</h1><p>My first paragraph.</p></body></html>"
}'
The response will be a PDF file generated from the HTML input.
Run H2P from Command Line (No Docker Compose)
If you don't want to use Docker Compose, you can run the H2P container manually with a single command:
docker run -d --name h2p -p 3000:3000 dacinfomotion/h2p:latest
This will:
- Download the h2p image (if not already available locally)
- Run it in the background (-d)
- Expose it on http://localhost:3000
Try it out using the same curl
command as above.
Stopping and Removing the H2P Container
To stop the running H2P container:
docker kill h2p
To remove the stopped container:
docker rm h2p
To also remove the Docker image from your system:
docker rmi dacinfomotion/h2p:latest