create_pdf
Use this action to render an HTML template to a PDF file that later actions can use.
Read the live config shape of each action type from GET /v1/automation/meta/action before you build on it.
In the automation editor, this action is Create a PDF in the Email & documents family. Its group is action, and it works with every trigger.
Send it in the actions array of Create an automation or Update an automation. An update replaces the whole array, so include the other actions.
Example
This action renders an invoice for the current record:
{
"type": "create_pdf",
"config": {
"filename": ["invoice-", { "kind": "variable", "source": "meta", "meta_type": "app_record_id", "app_id": 87 }, ".pdf"],
"page_size": "a4",
"page_orientation": "portrait",
"page_margins": "normal",
"pdf_body": ["<h1>Invoice</h1><p>Thank you for your order.</p>"],
"custom_variable_def": { "custom_type": "single_file", "label": "Invoice PDF" }
}
}
Config
Every key is optional. Tape fills in the same defaults as the editor, so a short config still gives a complete action.
| Property | Type | Description | Example value |
|---|---|---|---|
filename | template value | Name of the generated file. Empty when left out. | ["invoice.pdf"] |
custom_variable_def | object | The output variable that holds the generated PDF file. Default { "custom_type": "single_file", "label": "PDF" }. | { "custom_type": "single_file", "label": "Invoice PDF" } |
pdf_body | template value | HTML template for the PDF content. Empty when left out. | ["<h1>Invoice</h1>"] |
page_size | enum | Page size. Default a4. See Page sizes. | "a4" |
page_custom_width | code value | Custom page width. Used only when page_size is custom_size. Empty when left out. | ["210"] |
page_custom_height | code value | Custom page height. Used only when page_size is custom_size. Empty when left out. | ["297"] |
page_orientation | enum | Page orientation: portrait or landscape. Default portrait. | "portrait" |
page_margins | enum | Page margin preset. Default normal. See Page margins. | "normal" |
page_custom_margin_top | code value | Custom top margin. Used only when page_margins is custom_margins. Empty when left out. | ["20"] |
page_custom_margin_right | code value | Custom right margin. Used only when page_margins is custom_margins. Empty when left out. | ["15"] |
page_custom_margin_bottom | code value | Custom bottom margin. Used only when page_margins is custom_margins. Empty when left out. | ["20"] |
page_custom_margin_left | code value | Custom left margin. Used only when page_margins is custom_margins. Empty when left out. | ["15"] |
pdf_header_custom_margin_top | code value | Custom top margin of the header. Used only when page_margins is custom_margins. Empty when left out. | ["10"] |
pdf_footer_custom_margin_bottom | code value | Custom bottom margin of the footer. Used only when page_margins is custom_margins. Empty when left out. | ["10"] |
page_numbers_enabled | boolean | Whether Tape adds page numbers. Default false. | true |
page_number_style | enum | Numbering style of the page numbers. Default decimal. See Page number styles. | "decimal" |
page_number_start | code value | The number of the first page. Empty when left out. | ["1"] |
header_and_footer_enabled | boolean | Whether Tape adds the header and footer. Default false. | true |
pdf_header | template value | HTML template for the header on the first page. Empty when left out. | ["<p>Acme Inc.</p>"] |
pdf_header_following_pages_enabled | boolean | Whether the following pages get their own header. Default false. | false |
pdf_header_following_pages | template value | HTML template for the header on the following pages. Empty when left out. | ["<p>Invoice, continued</p>"] |
pdf_footer | template value | HTML template for the footer on the first page. Empty when left out. | ["<p>Thank you for your business.</p>"] |
pdf_footer_following_pages_enabled | boolean | Whether the following pages get their own footer. Default false. | false |
pdf_footer_following_pages | template value | HTML template for the footer on the following pages. Empty when left out. | ["<p>Acme Inc.</p>"] |
options_expanded | boolean | Editor only: whether the advanced options section shows expanded. Default false. | false |
pdf_header_expanded | boolean | Editor only: whether the header section shows expanded. Default true. | true |
pdf_footer_expanded | boolean | Editor only: whether the footer section shows expanded. Default true. | true |
pdf_body_expanded | boolean | Editor only: whether the body section shows expanded. Default true. Stays true while header_and_footer_enabled is false. | true |
Page sizes
page_size takes one of these lower-case tokens:
lettertabloidlegala3a4a5envelope_10custom_size: usespage_custom_widthandpage_custom_height.
Page margins
page_margins takes one of these lower-case tokens:
normalnarrowmoderatewidecustom_margins: uses the fourpage_custom_margin_*values and the header and footer margins.
Page number styles
page_number_style takes one of these lower-case tokens:
decimal: 1, 2, 3decimal_leading_zero: 01, 02, 03lower_latin: a, b, cupper_latin: A, B, Clower_roman: i, ii, iiiupper_roman: I, II, III
Editor-only flags
The four *_expanded keys only control which sections the automation editor shows expanded. They don't change the PDF.
meta/actionlists them in theconfig_schema.- Tape keeps them on read and write, so a read-modify-write preserves them.
- While
header_and_footer_enabledisfalse, Tape setspdf_body_expandedtotrue. In that state the editor has no control to open a closed body section.
Use the file in a later action
The action stores the file in the variable from custom_variable_def. A later action reads it with a custom reference that has the same custom_type and label. This send_email entry attaches the invoice:
{
"type": "send_email",
"config": {
"to_address": ["juliet@acme.com"],
"subject": ["Your invoice"],
"attach_files_variable_defs": [
{ "kind": "variable", "source": "custom", "custom_type": "single_file", "label": "Invoice PDF" }
]
}
}
General behavior
- The defaults are the ones in the Config table. Without
custom_variable_def, the output variable has the labelPDF. - Tape ignores the custom sizes and margins unless
page_sizeiscustom_sizeorpage_marginsiscustom_margins. - Code values for sizes, margins and
page_number_startmust resolve to a number. - Tape reads custom sizes and margins in millimeters, so
["210"]by["297"]is A4. - The action writes no reliable success entry to the run log. Don't use the log to confirm that the PDF was rendered.
Requirements
- To add or change this action through the API, your token needs the
automations:editcapability. See Capabilities. - You must administer the workspace that the automation's database app belongs to.