Document generation options in n8n
Getting started with n8n
This article is dedicated to advanced features of our n8n integration. If you wish to learn how to generate your first Document using n8n, we have a dedicated guide you can read:
Generating your first Document with n8nPayload Input Methods
The PDFMonkey node offers two ways to send data to your template:
Key-Value Pairs (Simple Mode)
This is the easiest way to send simple data structures. You can add fields one by one:

Each field has:
Key: The variable name in your template
Value: The data to send (can be static or dynamic from previous nodes)
JSON Format (Advanced Mode)
For complex data structures, nested objects, or arrays, use the JSON format:

Example of a complex JSON payload:
{
"customer": {
"name": "Acme Inc.",
"email": "[email protected]",
"address": {
"street": "123 Main St",
"city": "New York",
"zip": "10001"
}
},
"items": [
{
"product": "Widget",
"quantity": 5,
"price": 10.99
},
{
"product": "Gadget",
"quantity": 2,
"price": 24.99
}
],
"total": 104.93
}
In your template, you can access nested data like this:
Working with n8n expressions
One of n8n's most powerful features is the ability to use expressions to reference data from previous nodes:
{{ $json.customerName }} // Simple field
{{ $node["Webhook"].json["email"] }} // From specific node
{{ $json.items.length }} // Array length
{{ new Date().toISOString() }} // Current date
You can use these expressions in:
Key-Value pair values
JSON payload (as string values)
Custom filename
Metadata
Custom Filename
You can specify a custom name for the generated PDF. This is useful when storing files in Google Drive, Dropbox, or other storage services.
In the PDFMonkey node options:
Expand Additional Options
Set Custom Filename
Use a static name or n8n expressions:
Invoice-{{ $json.invoiceNumber }}.pdf
Report-{{ $now.format('YYYY-MM-DD') }}.pdf
{{ $json.customerName }}-Contract.pdf
Filename restrictions
Do not use slashes
/
or backslashes\
Avoid special characters that might cause issues on different operating systems
Non-latin characters may be escaped or replaced
Attaching metadata to your Documents
Metadata is additional information attached to a document that doesn't appear in the PDF itself. It's useful for:
Tracking document origin
Storing reference IDs
Filtering in webhooks
To add metadata:
Expand Additional Options in the PDFMonkey node
Set Metadata to Key-Value Pairs or JSON
Add your metadata fields:
{
"orderId": "ORD-12345",
"customerEmail": "[email protected]",
"environment": "production"
}
You can retrieve metadata later using the Get Document operation or in webhook triggers.
Wait for Document
By default, the Generate Document operation waits for the PDF to be fully generated before continuing.
Using arrays and complex data
n8n makes it easy to work with arrays from previous nodes. Here's how to pass arrays to PDFMonkey:
Example: Google Sheets to Invoice
If you have line items in Google Sheets:
Google Sheets node output:
[
{ "product": "Widget", "qty": 5, "price": 10 },
{ "product": "Gadget", "qty": 2, "price": 25 }
]
In PDFMonkey node (JSON mode):
{
"customerName": "{{ $json.customerName }}",
"items": {{ $node["Google Sheets"].json }}
}
The array will be passed directly to your template where you can loop over it:
{% for item in items %}
<tr>
<td>{{item.product}}</td>
<td>{{item.qty}}</td>
<td>{{item.price}}€</td>
</tr>
{% endfor %}
Handling multiple items (looping)
If your workflow processes multiple items (like multiple customers or orders), you can use n8n's Split In Batches node:
1. Get Data (returns 100 items)
2. Split In Batches (batch size: 1)
3. PDFMonkey - Generate Document (runs 100 times)
4. Store PDFs
Or use the Loop Over Items node for more control.
Rate limits
Be mindful of your PDFMonkey plan limits when generating multiple documents. Consider adding Wait nodes between batches if generating many PDFs.
Error handling
Use n8n's error handling features to manage failures:
Click on the PDFMonkey node
Go to Settings tab
Configure On Error:
Stop Workflow (default)
Continue With Last Successful Item
Continue Execution
For more robust error handling, add an IF node after PDFMonkey to check the status:
IF: {{ $json.status }} equals "success"
→ TRUE: Continue with PDF
→ FALSE: Send error notification
Related articles
Reacting to generated documents in n8nOther operations (Get, Download, Delete)Last updated
Was this helpful?