Skip to main content
Automation API

create_pdf

Use this action to render an HTML template to a PDF file that later actions can use.

Tip

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.

PropertyTypeDescriptionExample value
filenametemplate valueName of the generated file. Empty when left out.["invoice.pdf"]
custom_variable_defobjectThe output variable that holds the generated PDF file. Default { "custom_type": "single_file", "label": "PDF" }.{ "custom_type": "single_file", "label": "Invoice PDF" }
pdf_bodytemplate valueHTML template for the PDF content. Empty when left out.["<h1>Invoice</h1>"]
page_sizeenumPage size. Default a4. See Page sizes."a4"
page_custom_widthcode valueCustom page width. Used only when page_size is custom_size. Empty when left out.["210"]
page_custom_heightcode valueCustom page height. Used only when page_size is custom_size. Empty when left out.["297"]
page_orientationenumPage orientation: portrait or landscape. Default portrait."portrait"
page_marginsenumPage margin preset. Default normal. See Page margins."normal"
page_custom_margin_topcode valueCustom top margin. Used only when page_margins is custom_margins. Empty when left out.["20"]
page_custom_margin_rightcode valueCustom right margin. Used only when page_margins is custom_margins. Empty when left out.["15"]
page_custom_margin_bottomcode valueCustom bottom margin. Used only when page_margins is custom_margins. Empty when left out.["20"]
page_custom_margin_leftcode valueCustom left margin. Used only when page_margins is custom_margins. Empty when left out.["15"]
pdf_header_custom_margin_topcode valueCustom top margin of the header. Used only when page_margins is custom_margins. Empty when left out.["10"]
pdf_footer_custom_margin_bottomcode valueCustom bottom margin of the footer. Used only when page_margins is custom_margins. Empty when left out.["10"]
page_numbers_enabledbooleanWhether Tape adds page numbers. Default false.true
page_number_styleenumNumbering style of the page numbers. Default decimal. See Page number styles."decimal"
page_number_startcode valueThe number of the first page. Empty when left out.["1"]
header_and_footer_enabledbooleanWhether Tape adds the header and footer. Default false.true
pdf_headertemplate valueHTML template for the header on the first page. Empty when left out.["<p>Acme Inc.</p>"]
pdf_header_following_pages_enabledbooleanWhether the following pages get their own header. Default false.false
pdf_header_following_pagestemplate valueHTML template for the header on the following pages. Empty when left out.["<p>Invoice, continued</p>"]
pdf_footertemplate valueHTML template for the footer on the first page. Empty when left out.["<p>Thank you for your business.</p>"]
pdf_footer_following_pages_enabledbooleanWhether the following pages get their own footer. Default false.false
pdf_footer_following_pagestemplate valueHTML template for the footer on the following pages. Empty when left out.["<p>Acme Inc.</p>"]
options_expandedbooleanEditor only: whether the advanced options section shows expanded. Default false.false
pdf_header_expandedbooleanEditor only: whether the header section shows expanded. Default true.true
pdf_footer_expandedbooleanEditor only: whether the footer section shows expanded. Default true.true
pdf_body_expandedbooleanEditor 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:

  • letter
  • tabloid
  • legal
  • a3
  • a4
  • a5
  • envelope_10
  • custom_size: uses page_custom_width and page_custom_height.

Page margins​

page_margins takes one of these lower-case tokens:

  • normal
  • narrow
  • moderate
  • wide
  • custom_margins: uses the four page_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, 3
  • decimal_leading_zero: 01, 02, 03
  • lower_latin: a, b, c
  • upper_latin: A, B, C
  • lower_roman: i, ii, iii
  • upper_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/action lists them in the config_schema.
  • Tape keeps them on read and write, so a read-modify-write preserves them.
  • While header_and_footer_enabled is false, Tape sets pdf_body_expanded to true. 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 label PDF.
  • Tape ignores the custom sizes and margins unless page_size is custom_size or page_margins is custom_margins.
  • Code values for sizes, margins and page_number_start must 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:edit capability. See Capabilities.
  • You must administer the workspace that the automation's database app belongs to.

Next steps​