Essentials
Generate PDFs
Learn how to generate PDF files, such as invoices and certificates, from a template.
You can render any template as a PDF. This is useful for invoices, receipts, labels, and certificates, where you design the layout once and fill in the details for each customer.
What a PDF contains
A generated PDF has one page. The page is as wide and as high in points as the canvas is in pixels, and its content is a rendered picture of the design. The text sits inside that picture, so a reader cannot select, copy, or search it.
The A4 @72dpi preset in the editor sets the canvas to 595 by 842, an A4 portrait page. The A4 @96dpi and A4 @300dpi presets make larger pages (794 by 1123 and 2480 by 3508 points).
Design the canvas for the longest content you expect, because a template does not grow to a second page.
Generate a PDF
- Create an API key on the API Keys page and copy the template id from the template card menu.
- Send a
POSTrequest to/v1/templates/createPdfwith a JSON body:
curl --request POST \
--url https://api.bannerify.co/v1/templates/createPdf \
--header 'Content-Type: application/json' \
--output invoice.pdf \
--data '{
"apiKey": "YOUR_API_KEY",
"templateId": "tpl_invoice",
"modifications": [
{ "name": "customer", "text": "Acme Studio" },
{
"name": "line-items",
"columns": ["Item", "Qty", "Total"],
"rows": [
{ "Item": "Pro plan", "Qty": 1, "Total": "$29.00" }
]
}
]
}'
- Read the response. The body is the PDF file, and the
Content-Typeheader isapplication/pdf.
A PDF request takes three fields: apiKey, templateId, and modifications. It has no format or quality option. Modifications explains how to fill text, images, and tables.
Get a link instead of a file
POST /v1/templates/createStoredPdf takes the same body and returns a URL in place of the bytes:
{
"url": "https://images.bannerify.co/files/0b3c1c1e-5d6f-4c52-9e0a-8f6a4c0f2a11.pdf"
}
Bannerify saves the file and serves it from its CDN at a public URL. On the Business and Enterprise plans you can also send an s3Config object to save the file to your own S3-compatible bucket. Storage and notifications lists its fields.
Use an SDK
The JavaScript, Python, PHP, and Go SDKs have a createPdf method that returns the bytes. No SDK wraps createStoredPdf, so call that endpoint over REST. Create images and PDFs shows the JavaScript version.
Quota and errors
Each PDF counts as one generation. Quota and limits lists what counts and which limits apply. A failed request returns JSON with an error object, and Errors lists the codes.