3 simple steps to generate your first PDF document
1. Create API Key
All of the API calls need to be authenticated.
Go to api keys page and create a new api key.
2. Create HTML template
PDF documents are generated by combining custom JSON data with HTML template. Our HTML templates support handlebars templating engine to make generation as dynamic and tailored as possible.
Go to templates page and create a new template using the following HTML
<html>
<h1>{{title}}</h1>
<table>
<thead>
<tr>
<th>Description</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
{{#each items}}
<tr>
<td>{{description}}</td>
<td>{{amount}}</td>
</tr>
{{~/each}}
</tbody>
</table>
</html>
3. Generate PDF document
Now we can start generating PDF documents. In this example we are going to use link as a delivery mode. To generate a document use the following cURL command. Link to the generated document will be in the response.
Replace variables
Replace
API_KEY_HERE
with your API key andTEMPLATE_ID_HERE
with template id
curl --request POST \
--url https://api.dynamopdf.com/api/v1/pdf/link \
--header 'accept: */*' \
--header 'authorization: Bearer API_KEY_HERE' \
--header 'content-type: application/json' \
--data '
{
"templateId": "TEMPLATE_ID_HERE",
"parameters": {
"title": "Bank statement",
"items": [
{
"description": "Amazon",
"amount": "142.14"
},
{
"description": "Target online",
"amount": "29.37"
}
]
}
}
'