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.

OperationoperationResult
Merge PDFsmergeOne PDF from several, in order
Split into filessplitA list of PDFs, by ranges or every N pages
Extract pagesextract_pagesA PDF with the chosen pages, in the order given
Count pagespage_countA number
Watermark / stamp textwatermarkA PDF with text across or in a corner of each page
Rotate pagesrotateA PDF with pages turned 90°, 180° or 270°
Fill form fieldsfill_formA PDF with its AcroForm fields filled, optionally flattened
Read form fieldsread_formThe form's fields and values

Inputs

  • PDF (source) for every operation except merge: a file object, a list (the first file), a storage:// 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

SettingKeyDefaultUsed by
Operationoperationmerge
Pagespagesall (extract: required)extract_pages, watermark, rotate
Rangesranges—split: groups separated by ;, such as 1-3; 4-6; 7-
Every N pagesevery_n1split, when there are no ranges
Texttext— (required)watermark: up to 500 characters, several lines allowed, expressions such as APPROVED {{=TODAY()}}
Positionpositioncenterwatermark: center (diagonal across the page), top, bottom, top-left, top-right, bottom-left, bottom-right
Sizefont_sizefitted to the page (centre), 12 (corners)watermark
Opacityopacity0.25 (centre), 0.8 (elsewhere)watermark: 0.02–1
Angleanglethe page diagonal (centre), 0 (elsewhere)watermark, in degrees (not shown in the designer)
Colourcolor#999999watermark: a hex colour
Degreesdegrees90rotate: added to each page's current rotation (rounded to 90°)
Fieldsfields—fill_form: a list of { "name", "value" } pairs (values are expressions)
Or all values at oncefield_values—fill_form: an object of field name → value ({{applicant}}); fields win where both name a field
Flattenflattenfalsefill_form: make the filled form read-only
Fail when a field does not existstrictfalsefill_form: otherwise unknown names are skipped with a warning
Output file nameoutput_namesee belowEvery operation that writes a PDF
Output variableoutput_varpdf_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

OperationVariables
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
{{form}} from Read form fields
{
  "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:

json
{ "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

Stamp an approved contract
{
  "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()}}".

Fill an application form and flatten it
{
  "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_fields also lists form values.
  • Send Email with {{pdf_file}} as an attachment.