Templates
Learn how to create, update and publish PDFMonkey Templates using our API.
The DocumentTemplate object
The DocumentTemplate object is how we call a template in PDFMonkey. Is it composed of:
HTML + Liquid for the (dynamic) content part
CSS for styling
Test Data for testing purposes
Settings for printing options and details
States
A template contains two sets of properties:
Draft properties for content that's not published yet (ex.
body_draft
,settings_draft
)Properties currently used when genrating a document (ex.
body
,settings
)
Attributes
id
Unique identifier.
app_id
Unique identifier of the Template's Workspace.
identifier
Human name.
edition_mode
Can be code
or visual
.
body
Published HTML + Liquid content currently used to generate documents
body_draft
Unpublished HTML + Liquid content, not yet used for generation
scss_style
Published CSS or SCSS styles to apply to the content. Does not apply to header/footer.
scss_style_draft
Unpublished CSS or SCSS style.
sample_data
Not used. This "published" version can be used to rollback changes applied to the draft version.
sample_data_draft
JSON Data used to test the Template. Not used for generation, only for preview.
settings
Published printing settings. See "Settings" below.
settings_draft
Unpublished printing settings. See "Settings" below.
pdf_engine_id
Unique identifier of the PDF Engine to use when generating documents. See "PDF Engines" below.
pdf_engine_draft_id
Unique identifier of the PDF Engine to preview the draft version of the template with. Can be useful to test a new engine in preview before switching the published version to it. See "PDF Engines" below.
template_folder_id
Unique identifier of a Folder to group the Template into.
ttl
Document expiration delay. See "TTL" below.
created_at
Time at which the template was created.
updated_at
Time at which the template was last updated.
auth_token
Generated. Not used.
checksum
Internal. Used mainly for the preview.
preview_url
This URL can be used to preview the Template using draft properties. This is what you can use to preview a Template when using an external editor to write it.
Settings
The settings
attribute (and its draft counterpart settings_draft
) is an object that contains various configuration options for the Template. These settings control the layout, formatting, and behavior of the generated Document.
footer
Configures the footer of the Document.
footer.left footer.center footer.right
Content for the left, center or right parts of the footer.
Magic tokens [page]
and [topage]
can be used.
HTML + Liquid is not supported.
header
Configures the header of the Document.
header.left header.center header.right
Content for the left, center or right parts of the header.
Magic tokens [page]
and [topage]
can be used.
HTML + Liquid is not supported.
inject_javascript
When set to true
, the Document’s payload (or Test Data) will be accessible in JavaScript using the $docPayload
variable.
Rendering the full payload can impact performance. Only use it when needed.
margin
Sets the margins of the Document.
margin.bottom margin.left margin.right margin.top
Sets the bottom, left, right or top margins of the Document.
Expressed in millimeters.
Default is 10
if set to null
or not defined.
orientation
Sets the page orientation. Can be either portrait
or landscape
.
paper_format
Specifies the paper format. Can be one of:
a0
a1
a2
a3
a4
a5
a6
letter
custom
paper_height
Sets the paper height in millimeters.
For non-custom paper sizes, this value is derived from the paper_format
attribute and will be ignored.
paper_width
Sets the paper width in millimeters.
For non-custom paper sizes, this value is derived from the paper_format
attribute and will be ignored.
use_emojis
When set to true
, enables emoji support (using [Noto Color Emoji](https://fonts.google.com/noto/specimen/Noto+Color+Emoji)) in the generated PDF.
use_paged
Specific to PDF Engine v3, when set to true
, the engine will wait for Paged.js to rendering to complete before generating the PDF. Other engines will ignore this setting.
PDF Engines
We provide different PDF Engines to generate documents. Each version has its own capabilities and limitations. The most recent and powerful one is v4. We strongly recommend using it.
The list of available PDF Engines can be found using the dedicated endpoint:
This endpoint currently returns the following:
API Requests
Last updated
Was this helpful?