Documents
PDF Tools
Merge, split, extract pages, count pages, watermark or stamp text, rotate pages, and fill or read PDF form fields.
PDF Tools (doc_pdf) changes PDFs: one step runs one operation. Every operation except Count pages and Read form fields saves a new PDF and leaves the original untouched.
| Operation | operation | Result |
|---|---|---|
| Merge PDFs | merge | One PDF from several, in order |
| Split into files | split | A list of PDFs, by ranges or every N pages |
| Extract pages | extract_pages | A PDF with the chosen pages, in the order given |
| Count pages | page_count | A number |
| Watermark / stamp text | watermark | A PDF with text across or in a corner of each page |
| Rotate pages | rotate | A PDF with pages turned 90°, 180° or 270° |
| Fill form fields | fill_form | A PDF with its AcroForm fields filled, optionally flattened |
| Read form fields | read_form | The form's fields and values |
Inputs
- PDF (
source) for every operation except merge: a file object, a list (the first file), astorage://reference, a URL or base64 content. It must be a PDF ("not a PDF — use Convert document first"); text is not accepted. - PDFs to merge (
sources): a list of files — every file of an Attachments field ({{form.attachments}}), or a JSON list of file variables ([{{contract_pdf}}, {{terms_pdf}}]).
Page ranges (pages, ranges) are 1-based: 1-3, 5, 8- (8 to the end), last, 3-last; a reversed range (5-1) gives the pages backwards.
Options
| Setting | Key | Default | Used by |
|---|---|---|---|
| Operation | operation | merge | |
| Pages | pages | all (extract: required) | extract_pages, watermark, rotate |
| Ranges | ranges | — | split: groups separated by ;, such as 1-3; 4-6; 7- |
| Every N pages | every_n | 1 | split, when there are no ranges |
| Text | text | — (required) | watermark: up to 500 characters, several lines allowed, expressions such as APPROVED {{=TODAY()}} |
| Position | position | center | watermark: center (diagonal across the page), top, bottom, top-left, top-right, bottom-left, bottom-right |
| Size | font_size | fitted to the page (centre), 12 (corners) | watermark |
| Opacity | opacity | 0.25 (centre), 0.8 (elsewhere) | watermark: 0.02–1 |
| Angle | angle | the page diagonal (centre), 0 (elsewhere) | watermark, in degrees (not shown in the designer) |
| Colour | color | #999999 | watermark: a hex colour |
| Degrees | degrees | 90 | rotate: added to each page's current rotation (rounded to 90°) |
| Fields | fields | — | fill_form: a list of { "name", "value" } pairs (values are expressions) |
| Or all values at once | field_values | — | fill_form: an object of field name → value ({{applicant}}); fields win where both name a field |
| Flatten | flatten | false | fill_form: make the filled form read-only |
| Fail when a field does not exist | strict | false | fill_form: otherwise unknown names are skipped with a warning |
| Output file name | output_name | see below | Every operation that writes a PDF |
| Output variable | output_var | pdf_file, pdf_files (split), page_count, form (read form) |
Default file names: merged.pdf, <source>-pages.pdf, <source>-part1.pdf, -part2… (split), <source>-stamped.pdf, <source>-rotated.pdf, <source>-filled.pdf. With an output file name, split names its parts <name>-part1.pdf….
Form values: text fields take text, checkboxes true / false (also yes, on, 1, x), radio groups and dropdowns one of their options, list boxes one option or a list. Use Read form fields first to see the names.
Outputs
| Operation | Variables |
|---|---|
| merge, extract_pages, watermark, rotate, fill_form | {{pdf_file}}: the new PDF as a file object; also {{file}} and {{file_url}} |
| split | {{pdf_files}}: a list of file objects; {{pdf_files_count}} |
| page_count | {{page_count}}: a number |
| read_form | {{form}}: { fields, values }; {{form_values}}: field name → value |
{
"fields": [
{ "name": "approver", "type": "text", "value": "Nancy Davolio", "read_only": false, "required": false },
{ "name": "approved", "type": "checkbox", "value": true, "read_only": false, "required": false },
{ "name": "region", "type": "dropdown", "value": "Oceania", "options": ["Europe", "North America", "Oceania"], "read_only": false, "required": false }
],
"values": { "approver": "Nancy Davolio", "approved": true, "region": "Oceania" }
}Field types: text, checkbox, radio, dropdown, list, signature, button.
The run history for a watermark:
{ "variable": "stamped", "operation": "watermark", "file": "Supply agreement 1042-stamped.pdf", "size": 9132, "pages_stamped": 3 }Merge adds pages and files, split files and ranges, fill filled and missing, read form fields, count pages.
On the canvas
The operation and its main setting: Merge PDFs, Extract pages 1-3, Split 1-3; 4-6, Watermark "APPROVED" (the first 20 characters of the text as written), Fill form.
Limits
- Merge: at most 50 files, together at most 4 ×
DOCUMENT_MAX_MB(100 MB by default). Split: at most 500 files. - Encrypted (password-protected) PDFs cannot be changed.
- Watermark text uses Helvetica Bold, a standard PDF font: characters outside Latin (Windows-1252) are replaced with "?" and logged as a warning.
- Fill form works on standard (AcroForm) fields. Flattening can fail on unusual forms; that is logged as a warning and the form is left fillable.
Security notes
PDFs are processed with @cantoo/pdf-lib in the app's process; nothing is sent elsewhere. Inputs are read for this workspace only. See Security.
Example
{
"type": "doc_pdf",
"label": "Stamp approved",
"config": {
"operation": "watermark",
"source": "{{contract_pdf}}",
"text": "APPROVED",
"position": "top-right",
"color": "#1B7F3B",
"output_var": "stamped"
}
}Canvas: Watermark "APPROVED". For a dated stamp, use "text": "APPROVED {{=TODAY()}}".
{
"type": "doc_pdf",
"label": "Fill credit application",
"config": {
"operation": "fill_form",
"source": "{{credit_form_template}}",
"fields": [
{ "name": "company", "value": "{{customer.company_name}}" },
{ "name": "contact", "value": "{{customer.contact_name}}" },
{ "name": "approved", "value": "{{approved}}" }
],
"flatten": true,
"output_name": "Credit application {{customer.customer_id}}"
}
}Canvas: Fill form.
Works well with
- Convert Document to make a PDF from Word, HTML or Markdown first.
- Loop For Each over
{{pdf_files}}after a split, to send each part on. - Read Document for the text of the pages; its
structure.form_fieldsalso lists form values. - Send Email with
{{pdf_file}}as an attachment.