This minimalistic service renders an HTML template with Mustache and returns a PDF in DIN-A4 format.
Do a POST
request to your /renderPdf
endpoint with the following body:
{
"template":"Invoice {{invoiceNumber}} goes to {{billTo.name}}, {{billTo.street}} {{billTo.zip}} {{billTo.city}}",
"data":{
"invoiceNumber":"666"
"billTo": {
"name": "John Doe",
"street": "8213 Mainstreet",
"zip": "90210",
"city": "Beverly Hills, CA"
}
},
"desiredFilename": "invoice.pdf"
}
This will result in the following PDF
You'll find a more sophisticated example in the examples
folder.
- AWS Account
- Docker
- Homebrew (if you're on macOS)
- AWS SAM CLI
Start the local api using sam local start-api
. Then you're ready to call the service.
curl -X "POST" "http://127.0.0.1:3000/renderPdf" \
-H 'Accept: application/pdf' \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{
"template": "Invoice {{invoiceNumber}} goes to {{billTo.name}}, {{billTo.street}} {{billTo.zip}} {{billTo.city}}",
"data": {
"invoiceNumber": "666",
"billTo": {
"name": "John Doe",
"street": "8213 Mainstreet",
"zip": "90210",
"city": "Beverly Hills, CA"
}
},
"desiredFilename": "invoice.pdf"
}'
Deployment to AWS is pretty easy. Just type sam build
then sam deploy --guided
.