Link Search Menu Expand Document

Macros for text, built-in macros and using custom data for custom macros for auto text replacement

You can use built-in and custom macros inside text when using pdf/edit/add (or PDF Filler module in Zapier, Integromat/Make etc). Macro looks like this: {{$$newLine}} (built-in) or {{object.property}} (when referencing a custom data from JSON).

Built-in macros

Built-in macros always use $$ prefix.

List of built-in macros

  • {{$$PageNumber}} provides current page number (starts with 1)
  • {{$$PageCount}} provides page count
  • {{$$newLine}} replaced with a new line

Custom macros

Load JSON with custom data into templateData property. And then you can use data from this JSON as {{name}} or {{object.property}} macros.

Example:

POST /pdf/edit/add
{
    "url": "https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-edit/sample.pdf",
    "templateData": "{ \"firstName\": \"John\",  \"lastName\": \"Doe\",  \"age\": 26,   \"address\": {        \"streetAddress\": \"Market Street\",  \"city\": \"San-Francisco\",        \"postalCode\": \"94100\"    },    \"phoneNumbers\": [        {            \"type\": \"iPhone\",            \"number\": \"0123-4567-8888\"        },        {            \"type\": \"home\",            \"number\": \"0123-4567-8910\"        }    ]}",

    "annotations": [
        {
            "text": "{{firstName}} {{lastName}}\n{{address.streetAddress}}{{$$newLine}}{{phoneNumbers[0].number}}",
            "x": 250,
            "y": 100,
            "width": 150,
            "height": 100,
            "size": 12,
            "pages": "0-",
            "type": "TextFieldMultiline",
            "id": "multiline1"
        }
    ]
}

NOTE: JSON loaded into .templateData should be escaped (with JSON.stringify(dataObject) in JS). Escaping is when every " is replaced with \" (most programming languages are doing it automatically though.

Non-escaped JSON:

"templateData": "{ 'paid': true, 'invoice_id': '0002', 'total': '$999.99' }"

Escaped JSON (with " be escaped as \"):

"templateData": "{ \"paid\": true, \"invoice_id\": \"0002\", \"total\": \"$999.99\" }"