A simple Node Express.js API to convert Html document to Pdf using Puppeteer.
- Build image named html-to-pdf-converter -
docker build . -t html-to-pdf-converter
- Run image on port 80 -
docker run -itd --name html-to-pdf-converter -p 80:80 html-to-pdf-converter
- Build project -
npm install
- Run project (default port is 80) -
node index.js
- Run image on port 80 -
docker run -itd --name html-to-pdf-converter -p 80:80 hasitha2kandy/html-to-pdf-converter
- Using curl
curl --location --request POST 'http://localhost:80/api/generate/pdf' \
--header 'Content-Type: application/json' \
--data-raw '{
"Html": "<h1>Your pdf html string comes here</h1>"
}'
- Using Http
POST /api/generate/pdf HTTP/1.1
Host: localhost:80
Content-Type: application/json
Content-Length: 40
{
"Html": "<h1>Your pdf html string comes here</h1>",
"Format": "A4",
"Orientation":"Portrait"
}