
Email-to-Booklet: Parse, Personalize, and Merge Legal PDFs with n8n + PDF.co
6 MIN READ
6 MIN READ
By the end of this tutorial, you’ll have an automated workflow that:
financial_report.This automation ensures that invoices embedded in bulk financial reports are extracted, cleaned, and saved automatically—no more manual searching or splitting.
Before you begin, make sure you have:
The workflow uses the PDF.co community node, which must be installed before importing the JSON blueprint.
n8n-nodes-pdfcoIf you imported the blueprint before installing the PDF.co node and the nodes are missing, install the package, reload n8n, and import the workflow again.
Follow the detailed steps below to recreate the automation from scratch.
Here’s what the finished workflow does:
Invoice No.Node: Email Trigger (IMAP)
Settings:
INBOXMark as ReadTrueCustom Email Rules: ["UNSEEN", ["SUBJECT", "financial_report"]]
Success looks like: When a new/unread email with subject financial_report arrives, the workflow is triggered and the attached PDF is pulled in.
Node: PDF.co API → Upload File
Settings:
Upload File to PDF.coTruefile0={{ $json.subject }}Success looks like: The PDF financial report is uploaded to PDF.co and returns a secure file URL.
Node: PDF.co API → Search in PDF
Settings:
={{ $json.url }} (from Step 2)"Invoice No"Success looks like: PDF.co returns an array of all pages containing the text Invoice No.
Node: Code (JavaScript)
// Get the body array from the previous node
const body = $input.first().json.body || [];
// Extract pageIndex values
const pageIndexes = body.map(entry => entry.pageIndex);
// Convert to human-readable page numbers (index + 1), remove duplicates, and sort
const pageNumbers = [...new Set(pageIndexes.map(i => i + 1))].sort((a, b) => a - b);
// Return result
return [{
json: {
pageNumbers: pageNumbers, // [1, 4, 5]
pageNumbersCsv: pageNumbers.join(",") // "1,4,5" for APIs that need string
}
}];Logic:
pageIndex values from Step 3.Exports results as:
{
"pageNumbers": [1, 4, 5],
"pageNumbersCsv": "1,4,5"
}
Success looks like: Invoice page numbers are extracted and formatted for the Split API.
Node: PDF.co API → Split PDF
Settings:
={{ $('Assign URLs to Binary Files').item.json.url }}={{ $json.pageNumbersCsv }}Success looks like: A new set of PDF files, each containing only invoice pages, is returned.
Node: PDF.co API → Parse
Settings:
={{ $json.body[0] }}Success looks like: Customer information (e.g., company name, contact details) is extracted from the invoice.
Node: PDF.co API → Merge PDF
Settings:
Input URLs:
={{ $('Split File to get Invoices').item.json.body[0] }}
={{ $('Split File to get Invoices').item.json.body[1] }}
Output File Name: {{$json.body.vendor.name}}_merged_invoice.pdf
Success looks like: Multiple invoices are combined into a single professional PDF.
Node: HTTP Request
Settings:
={{ $json.url }}1500 msSuccess looks like: The merged invoice is converted into binary format for upload.
Node: Google Drive
Settings:
My DriveOUTPUT1 (Google Drive folder link)Success looks like: The final invoice PDF is saved to your Google Drive folder.
financial_report and a PDF attachment.You’ve successfully automated financial report invoice extraction. Your workflow now:
This setup can be extended further—for example, sending extracted invoice data to Airtable, QuickBooks, or Slack for notifications.
Built something cool? Share it with us on Twitter @pdfdotco!

6 MIN READ

6 MIN READ

6 MIN READ

6 MIN READ
Create an account, get an API key and test a request.