
Email-to-Booklet: Parse, Personalize, and Merge Legal PDFs with n8n + PDF.co
6 MIN READ
5 MIN READ
A fully automated system that watches a Google Drive folder for new invoice PDFs, sends each file to PDF.co to search the text “Acme Inc.” and replace it with your logo image, then downloads the updated PDF and re-uploads it to Google Drive with a timestamped filename (e.g., Invoice-1234-logoUpdated-2025-10-25_13-33-37_GMT.pdf). The timestamped filename is created with a short JavaScript Code node (included below).
Before you begin, make sure you have:
Important: Install the PDF.co community node before importing the JSON workflow. The blueprint references this node, but n8n does not install community nodes automatically when a workflow is imported. If the node is missing, the PDF.co step may not appear or may be shown as an unrecognized node.
n8n-nodes-pdfco.The PDF.co package and its installation instructions are available on the n8n-nodes-pdfco package page.
Community-node installation must be permitted on your n8n instance. If you cannot access the Community Nodes settings, ask your n8n administrator to install the node.
After installing the PDF.co node:
Credentials are not included in exported n8n workflows. You must reconnect each application after importing the blueprint.
Follow the guide below to create it from scratch.
Why the HTTP Request node? The PDF.co node returns a URL to the processed PDF. We download that URL to get a binary file, which the Google Drive Upload node requires.
You drop Invoice-1234.pdf into the “Incoming Invoices” Drive folder. The workflow detects it → replaces “Acme Inc.” with your logo → uploads the updated file to “Updated Invoices” as:
Invoice-1234-logoUpdated-2025-10-25_13-33-37_GMT.pdf
What happens in this step
This node keeps an eye on a specific Drive folder. Each time a new file is added, it triggers the workflow and passes the file’s metadata downstream (name, id, webContentLink, etc.).
Node: Google Drive Trigger
Settings:
Success Looks Like
As soon as a PDF invoice lands in that folder, the flow runs and exposes fields like name, id, webContentLink in $json.
What happens in this step
We calculate two timestamps (pretty for logs; safe for filenames) and create newName by appending -logoUpdated-<timestamp>.pdf to the original file’s base name. This ensures every updated file has a clear “last updated” marker.
Node: Code (JavaScript)
Code (paste as-is):
// Adds two readable GMT timestamps and a new filename:
// tsDisplay: "YYYY-MM-DD HH:mm:ss GMT"
// tsFile: "YYYY-MM-DD_HH-mm-ss_GMT" (filename-safe)
// Also sets baseName (original name without .pdf) and newName.
function pad(n){ return n.toString().padStart(2,'0'); }
function buildTimestamps(){
const d = new Date(); // UTC/GMT basis
const Y = d.getUTCFullYear();
const M = pad(d.getUTCMonth() + 1);
const D = pad(d.getUTCDate());
const h = pad(d.getUTCHours());
const m = pad(d.getUTCMinutes());
const s = pad(d.getUTCSeconds());
const tsDisplay = `${Y}-${M}-${D} ${h}:${m}:${s} GMT`;
const tsFile = `${Y}-${M}-${D}_${h}-${m}-${s}_GMT`;
return { tsDisplay, tsFile };
}
const { tsDisplay, tsFile } = buildTimestamps();
return items.map(item => {
const original = (item.json?.name ?? '').toString();
const fallback = (item.json?.id ?? 'document');
const safeName = original || `${fallback}.pdf`;
// remove trailing .pdf (case-insensitive)
const baseName = safeName.replace(/\.pdf$/i, '') || 'document';
// build filename using the filename-safe timestamp
const newName = `${baseName}-logoUpdated-${tsFile}.pdf`;
// attach for downstream nodes
item.json.baseName = baseName;
item.json.tsDisplay = tsDisplay; // e.g., "2025-10-25 13:33:37 GMT"
item.json.tsFile = tsFile; // e.g., "2025-10-25_13-33-37_GMT"
item.json.newName = newName;
return item;
});What this code does
.pdf from the original.-logoUpdated-<timestamp>.newName to $json so later nodes can use it directly.Success Looks Like
For Invoice-1234.pdf, the Code node produces: Invoice-1234-logoUpdated-2025-10-25_13-33-37_GMT.pdf
What happens in this step
We send the original invoice PDF to PDF.co, asking it to find the text “Acme Inc.” and replace each match with your logo image. PDF.co returns a URL to the updated PDF.
This calls the PDF.Co Search and Replace with Image endpoint behind the scenes.
Node: PDFco Api (PDF.co native)
Operation: Search & Replace Text or Delete
Parameters (key ones):
={{ $json.webContentLink }} (The link to your original Drive file. Ensure the file is shared appropriately so PDF.co can fetch it.)replaceWithImageAcme Inc. (case sensitive? If needed, many accounts support case-insensitive mode; else ensure exact casing in your docs)https://i.postimg.cc/L5734myM/LOGO2.png (use your logo URL)1-)={{ $json.newName }} (Good for labeling inside PDF.co; we still rename on upload.)What to expect
This node returns JSON like:
{
"status": "success",
"url": "https://pdf-temp-storage.s3.../updated.pdf",
"name": "Invoice-1234-logoUpdated-2025-10-25_13-33-37_GMT.pdf"
}That url points to the updated file, which we’ll download next.
What happens in this step
We take PDF.co’s result URL and download the file so we have a binary that the Google Drive Upload node accepts.
Node: HTTP Request
Settings:
GET={{ $json.url }}data={{ $json.newName }}Success Looks Like
The node now outputs a binary property named data representing the updated PDF content.
What happens in this step
We upload the binary file into your selected destination folder (e.g., OUTPUT1) in Google Drive, using the timestamped filename we built.
Node: Google Drive → Upload File
Settings:
data1KMbseCUfUSai6GT_ZgtdTVffdT6ZYn_o)={{ $json.newName }})Success Looks LikeThe updated, logo-replaced invoice appears in your output Drive folder with the new timestamped file name.
Google Drive Trigger
→ Code (build timestamped newName)
→ PDFco Api (search "Acme Inc." and replace with logo)// returns URL
→ HTTP Request (GET) // downloads to binary: data
→ Google Drive (Upload) // saves to destination folder
You now have a robust, timestamped, hands-off system that rebrands invoices on arrival — replacing “Acme Inc.” with your logo — and files them neatly in Google Drive for easy sharing and auditing.
Share your automation success with the community and tag @pdfdotco — we love seeing creative n8n + PDF.co workflows!

6 MIN READ

6 MIN READ

6 MIN READ

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