Auto-Replace Company Name with Logo in PDFs: End-to-End Workflow
What You’ll Have When Done
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).
Prerequisites
Before you begin, make sure you have:
- A PDF.co API Key – get one at https://app.pdf.co/
- Google Drive OAuth2 credentials configured in n8n
- An n8n instance (Cloud or self-hosted)
- A Google Drive folder for incoming invoices (the folder you’ll watch)
- A Google Drive folder for updated invoices (where the modified PDFs will be saved)
- Your logo image URL (publicly reachable), e.g.: https://i.postimg.cc/L5734myM/LOGO2.pngSample Invoice: Link Here
Important: If you pass Drive file links (like webContentLink) to PDF.co, set the file’s sharing to “Anyone with the link” or ensure the link is otherwise accessible to PDF.co.
Quick Start Options
Option A: I Want It Working Now
- Import your workflow JSON.
- Connect your Google Drive and PDF.co accounts in the nodes.
- In the Google Drive Trigger, choose your source folder (incoming invoices).
- In the Google Drive (Upload) node, choose your destination folder (updated invoices).
- In the PDFco Api node, set Search String (Acme Inc.) and Replace Image URL (your logo).
- Test by dropping a sample invoice PDF into the watched folder.
- Activate and let it run.
Option B: I Want to Build It Step-by-Step
Follow the guide below to create it from scratch.
What This Automation Does (Overview)
- Monitors a Google Drive folder for new PDFs (invoices).
- Generates a timestamped filename for the updated copy using a Code node.
- Calls PDF.co to search the text “Acme Inc.” and replace it with your logo image in the PDF.
- Downloads the updated PDF from PDF.co via an HTTP Request (GET) node (this is where we get the binary).
- Uploads the updated binary PDF to Google Drive, into your destination folder, using the new timestamped name.
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.
Real Example
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
Step-by-Step Build Guide
Step 1: Watch Drive for New Invoices
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:
- Trigger On: Changes Involving a Specific Folder
- Folder: (select your source folder, e.g., INPUT-1)
- Watch For: File Created
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.
Step 2: Build a Timestamped Filename (Code)
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
- Builds a GMT timestamp in two styles.
- Derives a base name by stripping
.pdffrom the original. - Assembles a new filename that includes
-logoUpdated-<timestamp>. - Attaches
newNameto$jsonso 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
Step 3: Search “Acme Inc.” and Replace with Logo (PDF.co)
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):
- Input URL:
={{ $json.webContentLink }}(The link to your original Drive file. Ensure the file is shared appropriately so PDF.co can fetch it.) - Operation Type:
replaceWithImage - Search String (for Replace With Image):
Acme Inc.(case sensitive? If needed, many accounts support case-insensitive mode; else ensure exact casing in your docs) - Replace Image URL:
https://i.postimg.cc/L5734myM/LOGO2.png(use your logo URL) - Pages: (Leave blank for all pages. If your node has “0” by default and it doesn’t replace on all pages, clear it or set a range like
1-) - Advanced → File Name:
={{ $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.
Step 4: Download Updated PDF as Binary
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:
- Method:
GET - URL:
={{ $json.url }} - Response: File
- Binary Property:
data - File Name:
={{ $json.newName }}
Success Looks Like
The node now outputs a binary property named data representing the updated PDF content.
Step 5: Upload Updated PDF to Google Drive
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:
- Operation: Upload
- Binary Property:
data - Drive: My Drive (or your drive)
- Parent Folder (by ID): (choose your output folder ID, e.g.,
1KMbseCUfUSai6GT_ZgtdTVffdT6ZYn_o) - (File Name is inherited from the binary; if needed you can set it to
={{ $json.newName }})
Success Looks LikeThe updated, logo-replaced invoice appears in your output Drive folder with the new timestamped file name.
Node Wiring (Visual Order)
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’re Done!
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.
Built Something Cool?
Share your automation success with the community and tag @pdfdotco — we love seeing creative n8n + PDF.co workflows!
Related Tutorials



