Create PDF From HTML

apitemplate.create_pdf_from_html
ActionBusiness appsconnection required

Calls the APITemplate.io API with the connection's credentials.

Render HTML markup, with optional CSS and Jinja2 tags, as a PDF.

Connection

Required
Yes — the node will not save without one
Auth type
API key
Providers
APITemplate.io
Secret shape
the API key, or {"api_key": "…"}
Config it needs
base_url
Resolved by
config.connection_id, else node.connection_id

Configuration

9 fields, 1 required. A dotted path is a nested object and name[] an array of objects — the editor renders the same tree.

FieldTypeRequiredDefaultConstraintsExample
body
The HTML to render. Jinja2 tags such as {{ name }} are filled from 'data'.
stringYes——<h1>Hello {{ name }}</h1>
css
CSS for the document, including the surrounding style tag.
stringNo——<style>body { font-family: sans-serif; }</style>
data
Values for the Jinja2 tags in the HTML body, as a JSON object.
objectNo——{"name":"Acme Ltd"}
settings
PDF print settings such as paper_size, orientation, margins and custom_header.
objectNo——{"margin_top":"40","orientation":"1","paper_size":"A4"}
export_type
How the result comes back: 'json' stores the file on APITemplate's CDN and returns a download_url, 'file' returns the document itself and stores nothing.
stringNojsonone of "json", "file"—
output_format
What to render the template as. Leave blank for APITemplate's default, a PDF.
stringNo—one of "pdf", "html", "png", "jpeg"—
filename
Name for the generated file, ending in the right extension. Defaults to a UUID.
stringNo——invoice-89326.pdf
expiration
Minutes before APITemplate deletes the file from its CDN. 0 keeps it permanently.
numberNo—0–10080—
meta
Your own reference for this render; it comes back on apitemplate.list_objects.
stringNo——inv-iwj343jospig

Example configuration

Every value below is the contract’s own example or default — nothing invented.

{
  "body": "<h1>Hello {{ name }}</h1>",
  "css": "<style>body { font-family: sans-serif; }</style>",
  "data": {
    "name": "Acme Ltd"
  },
  "export_type": "json",
  "filename": "invoice-89326.pdf",
  "meta": "inv-iwj343jospig",
  "settings": {
    "margin_top": "40",
    "orientation": "1",
    "paper_size": "A4"
  }
}

Output

One shape.

result

FieldTypeExample
status
APITemplate's own verdict for the render: 'success'.
string—
download_url
URL of the generated file on APITemplate's CDN; empty when export_type is 'file'.
string—
template_id
The template that was rendered.
string—
total_pages
How many pages the generated PDF has.
number—
transaction_ref
APITemplate's reference for this render; pass it to apitemplate.delete_object.
string—
post_actions
Results of any configured Post Actions, such as an upload to your own S3 bucket.
array—
file_content
The file, base64-encoded.
string—
content_encoding
stringbase64
filename
stringapp-main.zip
content_type
stringapplication/zip
size
Raw size in bytes (before base64).
number—
{
  "content_encoding": "base64",
  "content_type": "application/zip",
  "download_url": "",
  "file_content": "",
  "filename": "app-main.zip",
  "post_actions": [],
  "size": 0,
  "status": "",
  "template_id": "",
  "total_pages": 0,
  "transaction_ref": ""
}

Notes

  • Every render spends one of the account's API credits; apitemplate.account_information reports how many are left.
  • With export_type 'json' the file is stored on APITemplate's CDN and the node emits a download_url; with 'file' nothing is stored and the node emits the file itself.

See Create PDF From HTML run in a workflow.

In a technical demo we add the APITemplate.io connection, drop the node on the canvas and let Workflow Health pre-flight it before the first real run.