Español

Lee este artículo en español.

How to merge PDF files in n8n (one node)

If you generate documents with n8n (invoices, reports, contracts), sooner or later you need to merge several PDFs into one: the invoice with its terms and conditions, a report with its appendices, or a handful of loose attachments that need to go out as a single file. With the regular HTTP Request node and the Cofferdock API, you do it in one step, nothing to install.

Quick note: n8n has no dedicated "merge PDF" node. You do it with the HTTP Request node calling an API that combines them in the order you give it. Here's how, field by field.

What you'll get

You send 2 to 20 PDFs (as binary data) in the order you want them to end up in, and you get back a single PDF with every page in sequence. It costs the same 1 credit whether you merge 2 PDFs or 20.

Common uses in n8n:

What you need

Step by step in the HTTP Request node

The easiest setup is to have the input PDFs as binary properties on the same item (for example invoice and terms, if they come from two different steps, combine them onto one item first). Add an HTTP Request node and fill it in like this:

{
  "files": [
    "={{ $binary.invoice.data }}",
    "={{ $binary.terms.data }}"
  ],
  "output": "pdf"
}

With "output": "pdf" the node's output is already the merged PDF as a file, ready for Google Drive, Gmail, or the next step, no conversions needed.

A quick example

Say you generate an invoice and send it with its terms and conditions attached in the same PDF:

  1. An HTTP Request node to the HTML to PDF API that generates the invoice, stored in the invoice binary property.
  2. A node that fetches the fixed terms PDF (read from disk, or downloaded once with another HTTP Request), in the terms property.
  3. The HTTP Request node above, which merges both into a single PDF.
  4. A Gmail node that sends that single PDF to the customer.

The customer gets one file, not two loose attachments.

Prefer to see it in code?

The same call with curl, with the PDFs already in base64:

curl -X POST "https://api.cofferdock.com/pdf-merge?output=pdf" \
  -H "x-api-key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"files": ["BASE64_PDF_1", "BASE64_PDF_2"]}' \
  -o merged.pdf

How much does it cost?

Each merge uses 1 credit from your plan, whether it's 2 pages or 20. Every Cofferdock tool draws from the same pool of credits.

FAQ

Does n8n have a native node to merge PDFs? No. You do it with the HTTP Request node calling the Cofferdock API.

How many PDFs can I merge at once? Between 2 and 20 in the same call.

What order do the pages end up in? The same order they appear in the files array.

What happens if one of the files isn't a valid PDF? The call fails with a 400 error pointing to which position in the array has the problem, with no credit spent.

Can I get a link instead of the file? Yes. Set output to url and you'll get a temporary download link (15 minutes) instead of the PDF directly.

Related guides

Try it yourself

You'll find the full instructions, with copy-paste examples, on the merge PDF page. And if you don't have an account yet, you can create one for free and build your first flow today.