Tutorial
How to Automate PDF Generation with n8n: Step-by-Step Guide
You're copying the same data into the same PDF template every week. Client reports, invoices, certificates - the structure never changes, only the numbers do. That's hours of your life you're not getting back.
Here's the fix: n8n + Stencil gives you a fully automated PDF pipeline in minutes. Build your template once, connect it to any data source, and let the workflow handle the rest. This guide shows you exactly how.
Why n8n for PDF Automation?
n8n is an open-source workflow automation tool with a visual editor. You connect nodes - triggers, actions, logic - without writing code. It's like Zapier, but you can self-host it and there are no per-task limits.
For PDF generation, n8n pairs perfectly with an API like Stencil. Instead of coding HTML templates, wrestling with Puppeteer, and managing file storage yourself - which easily takes days - you get a visual template editor and a single HTTP request. The workflow looks like this:
Trigger
Google Sheets row, webhook, schedule
Generate
HTTP Request to Stencil API
Deliver
Email, Drive, Slack - anywhere
Prerequisites
Before you start, make sure you have:
- Stencil account - Free at stencilpdf.com (3 templates, unlimited generations)
- n8n instance - Cloud or self-hosted
- Basic n8n familiarity - You know how to add and connect nodes
Create Your PDF Template in Stencil
Open Stencil and create a new template. The drag-and-drop editor lets you place text, images, tables, and shapes exactly where you want them. No CSS, no code.
The key feature: dynamic fields. Anywhere you want data to change, type a placeholder wrapped in double curly braces:
{{client_name}} | {{invoice_total}} | {{report_date}}When you call the API later, you'll pass actual values for these fields. Stencil replaces them and generates the final PDF.
[Screenshot: Stencil template editor with variable fields highlighted]
Browse starter templates if you want a head start on invoices, reports, or certificates.
Get Your Stencil API Key
In your Stencil dashboard, go to Settings → API. Copy your API key - you'll need it to authenticate requests from n8n.
[Screenshot: Stencil API settings page]
Also note your template ID - visible in the URL when editing a template or in the template list.
Set Up the n8n Workflow
Here's where it comes together. We'll build a workflow that generates a client report whenever a new row is added to a Google Sheet.
Add your trigger
Search for "Google Sheets Trigger" and add it. Configure it to watch your spreadsheet for new rows. This fires every time someone adds data.
Add the HTTP Request node
Connect an HTTP Request node to your trigger. Configure it like this:
- Method: POST
- URL: https://app.stencilpdf.com/api/v1/generate
- Authentication: Header Auth with your API key
- Body Content Type: JSON
Pass the dynamic data
In the JSON body, reference values from the trigger using n8n expressions:
{
"template_id": "your_template_id",
"data": {
"client_name": "{{$json.client_name}}",
"report_date": "{{$json.date}}",
"invoice_total": "{{$json.total}}"
}
}The {{$json.client_name}} syntax pulls the value from the incoming Google Sheets row. Map each field to the corresponding column in your spreadsheet.
[Screenshot: n8n workflow with HTTP Request node configured]
Test and Download the PDF
Click "Test workflow" in n8n. The HTTP Request node will return a response containing your PDF URL. Open it - you should see your template with the actual data filled in.
Sync vs. Async: By default, Stencil generates PDFs synchronously - the response includes the URL immediately. For high-volume batches, you can use async mode with a webhook callback.
From here, add more nodes: send the PDF via email (Gmail, Outlook), upload to Google Drive or Dropbox, post to Slack, or store the URL in a database. The PDF URL is just data - route it anywhere.
Real-World Use Cases
Weekly Client Reports
Trigger: CRM updates on Friday. Workflow pulls client metrics from your database, generates a branded PDF report, and emails it directly to the client. Zero manual work.
Bulk Certificate Generation
You run a course with 200 participants. Upload their names to a Google Sheet. n8n generates 200 personalized certificates in minutes and stores them in Drive.
Automated Invoices
Stripe sends a webhook when a payment succeeds. n8n generates an invoice PDF with the transaction details and emails it to the customer automatically.
Stencil vs. Building Your Own n8n PDF Solution
You could roll your own: Puppeteer to render HTML, a server to host it, file storage for the output. It works. But here's the reality:
DIY with Puppeteer
- Days of development time
- HTML/CSS template maintenance
- Server infrastructure costs
- File storage setup
Stencil API
- Visual drag-and-drop editor
- No code, no maintenance
- Built-in file hosting
- Single HTTP request
Ready to automate?
n8n + Stencil removes the manual PDF step from any workflow. Whether it's reports, invoices, or certificates - build the template once and let automation handle the rest.
Your first 3 templates are free - no credit card required.

Author
stencil Team
We help businesses automate repetitive document work. From certificates to invoices – with stencil, every PDF becomes an API call.
Related Articles
