Zapier is good at moving one record from A to B and weak at loops, which is exactly why a PDF is usually the awkward step. This template moves the repetition into the HTML template, so the Zap stays a straight line of three steps even when the invoice has twenty lines.
600 free requests / month, no credit card
// live preview
The HTML on the left is what the action receives. The JSON on the right is what the trigger step maps into it. Render it to see the file the Zap attaches.
// the workflow
Add the CustomJS app as an action step, pick the PDF action, and map the trigger fields into it. The tricky part on Zapier is the line items, and the next section is about exactly that.
{
"invoiceNumber": "{{trigger__invoice_number}}",
"customerName": "{{trigger__customer_name}}",
"customerEmail": "{{trigger__customer_email}}",
"total": "{{trigger__total}}",
"currency": "USD",
"items": {{trigger__line_items_json}}
}// step by step
Add a step, search for CustomJS, and create a connection with the API key from your workspace. The Zapier integration page shows the screens.
Pick the HTML to PDF action. It takes the template and the data, and returns the finished file to the following steps.
This is where most Zaps go wrong. If the trigger gives you Zapier line items, use a Formatter, Utilities, Line Itemizer step to turn them into a JSON array first. If the source already stores them as JSON text, map that field straight through.
The action returns a file object, so the Gmail, Outlook, Drive and Dropbox steps accept it directly in their attachment or file field. No extra download step is needed.
// html template
Zapier has no repeat step in the ordinary plan, so a per line item render would mean one action run per row. Keeping the loop inside the template means one run per invoice, which is both faster and cheaper.
{% for item in items %}
<tr>
<td>{{ item.description }}</td>
<td class="num">{{ item.quantity }}</td>
<td class="num">{{ item.amount }}</td>
</tr>
{% endfor %}[
{ "description": "Starter plan, November", "quantity": 1, "amount": "490.00" },
{ "description": "Additional seats", "quantity": 4, "amount": "400.00" }
]A missing or malformed items array renders an invoice with an empty table rather than failing the Zap, so test with a real record before turning it on.
Turn invoice data from any n8n node into a finished PDF with one CustomJS node. Importable workflow, editable HTML template, no headless browser to run.
One HTML to PDF module turns the invoice data in your scenario into a finished document. Editable template, dynamic line items, output straight to Drive or email.
Create a workspace, connect the API key in Zapier, and the action is available in the picker.