Skip to main content

Replace Text With Image in n8n

Replace Text With Image is an n8n node by PDF4me that finds an exact text placeholder inside a PDF and swaps it for a logo, signature, or product image at matching dimensions. Use it for template branding, signature insertion, or automated visual personalization without manually editing the PDF.

What this node does

PDF4me: Replace Text With Image scans a PDF for an exact text string and replaces every matching occurrence with an image, scaled to your chosen height and width, on the pages you target. Accepts both the source PDF and the replacement image via Binary Data, Base64 String, or URL, independently. Ideal for inserting logos, signatures, stamps, or product photos into templated PDFs.

Related Blog Posts
No blog post yet for this feature — coming soon.
In the meantime, browse the PDF4me blog for tutorials and workflows across every platform.
Visit the blog

Authenticating Your API Request

Every PDF4me node in n8n requires a valid Credential to connect with. Create or select one that holds your PDF4me API key so the workflow can authenticate the replacement request securely.

Important Facts You Should Not Miss

Text to Replace must match exactly
PDF4me performs precise text matching, including spaces, punctuation, and capitalization. A placeholder like [LOGO_HERE] only matches that exact string, not a partial or case-different version.
PDF and image inputs are independent
PDF Input Data Type and Image Input Data Type are set separately, one can come from Binary Data while the other comes from a URL, useful when the template PDF and the logo live in different systems.
This is a PDF action, not the Word variant
A separate Replace Text With Image in Word Document node handles .docx files with Word-specific placeholders. Use this node only when the source document is already a PDF.
Replace Text With Image n8n node configured with Action Replace Text With Image, PDF Input Data Type Binary Data, PDF Binary Field data, Image Input Data Type Binary Data, Image Binary Field data, Text to Replace, Page Sequence all, Image Height 50, Image Width

PDF4me Replace Text With Image node parameters panel in n8n

What Parameters Does Replace Text With Image Need?

Required: PDF Input Data Type, Image Input Data Type, Text to Replace, Image Height, Image Width, and Output File Name. Conditional fields appear only when their parent Input Data Type is chosen. Page Sequence, Async, and Binary Data Output Name are optional with working defaults.

ParameterRequiredWhat it doesExample
PDF Input Data TypeRequiredFormat of the source PDF input. Choose Binary Data (from a previous node), Base64 String, or URL.Binary Data
PDF Binary FieldConditionalName of the binary property on the incoming n8n item that holds the source PDF. Required when PDF Input Data Type is Binary Data.data
Base64 PDF ContentConditionalBase64-encoded source PDF content. Required when PDF Input Data Type is Base64 String.JVBERi0xLjQK...
PDF URLConditionalPublicly reachable HTTPS URL to the source PDF. Required when PDF Input Data Type is URL.https://example.com/sample.pdf
Image Input Data TypeRequiredFormat of the replacement image input. Choose Binary Data, Base64 String, or URL, independent of the PDF input type.Binary Data
Image Binary FieldConditionalName of the binary property on the incoming n8n item that holds the replacement image. Required when Image Input Data Type is Binary Data.data
Base64 Image ContentConditionalBase64-encoded replacement image content. Required when Image Input Data Type is Base64 String./9j/4AAQSkZJRgAB...
Image URLConditionalPublicly reachable HTTPS URL to the replacement image. Required when Image Input Data Type is URL.https://example.com/logo.png
Text to ReplaceRequiredThe exact text string to find and replace with the image, matched precisely including case and punctuation.[LOGO_HERE]
Page SequenceOptionalPages to search for the placeholder. Use all, specific pages (1,3,5), or a range (1-5). Default all.all
Image HeightRequiredHeight in pixels to scale the replacement image to, maintaining aspect ratio.50
Image WidthRequiredWidth in pixels to scale the replacement image to, maintaining aspect ratio.100
Output File NameRequiredFilename for the resulting PDF, must include the .pdf extension.replace_text_with_image.pdf
AsyncOptionalEnables background processing for large PDFs. Default false.false
Binary Data Output NameOptionalName of the binary property the output item exposes. Default is data.data

Output Fields

A successful run returns one n8n item carrying JSON metadata and the updated binary PDF.

FieldTypeWhat it contains
successBooleanTrue when the replacement succeeded. Use to route error-handling branches.
messageStringHuman-readable status message for the replacement result.
fileNameStringGenerated filename, matching Output File Name.
mimeTypeStringMIME type of the output, always application/pdf.
fileSizeNumberSize of the resulting PDF in bytes.
pagesProcessedNumberNumber of pages searched for the placeholder text.
Binary (data)BinaryThe updated PDF under Binary Data Output Name (default data). Pass into Write Binary File, Email, or any cloud-storage upload.

How Do I Set Up Replace Text With Image in n8n?

  1. Add PDF4me to your n8n workflow and choose the Replace Text With Image action.
  2. In Credential to connect with, select your PDF4me credential or click Create New Credential and paste your API key.
  3. Set PDF Input Data Type and supply the source PDF via PDF Binary Field, Base64 PDF Content, or PDF URL.
  4. Set Image Input Data Type and supply the replacement image via Image Binary Field, Base64 Image Content, or Image URL.
  5. Enter Text to Replace exactly as it appears in the PDF, and set Page Sequence if you need to target specific pages.
  6. Set Image Height and Image Width to scale the replacement image, and set Output File Name.
  7. Enable Async for large PDFs if needed. Execute the node and route the updated PDF into the next step.

Typical Setups

Workflow ExamplesCommon n8n workflow patterns using Replace Text With Image.
Client logo insertion in a proposal template
  1. A CRM webhook fires when a new proposal is generated for a client.
  2. PDF4me Replace Text With Image runs with Text to Replace set to [CLIENT_LOGO] and Image Input Data Type URL pointing to the client's logo.
  3. The branded proposal is emailed to the sales rep for final review.
Signature stamp on a generated contract
  1. A contract is generated via PDF4me Generate Document with a [SIGNATURE] placeholder.
  2. PDF4me Replace Text With Image runs with the signatory's signature image and Page Sequence targeting only the final page.
  3. The signed-looking contract is archived to SharePoint.
Product image swap in a catalog PDF
  1. A Loop Over Items node iterates product records from an inventory database.
  2. PDF4me Replace Text With Image runs per item, replacing a [PRODUCT_IMAGE] placeholder with each product's photo from cloud storage.
  3. Each personalized catalog page is combined downstream into a single distributable PDF.
Approval stamp graphic after sign-off
  1. An approval webhook fires once a manager marks a document approved in an internal tool.
  2. PDF4me Replace Text With Image runs with a [APPROVAL_STAMP] placeholder swapped for an approval graphic.
  3. The finalized PDF is archived with the approval date in the filename.

Practical Tips

Use a distinctive placeholder string
A unique token like [CLIENT_LOGO] avoids accidentally matching unrelated text elsewhere in the document.
Match Image Height/Width to the source aspect ratio
Mismatched dimensions can stretch or squash the inserted image; check the source image proportions first.
Narrow Page Sequence when possible
Targeting only the pages that contain the placeholder is faster and avoids unintended matches on other pages.
PDF and image sources can differ
Pull the template PDF from Binary Data while sourcing the logo from a URL, or any other combination that fits your workflow.
Enable Async for large PDFs
Large documents benefit from asynchronous processing so the workflow execution does not time out.
Use the Word variant for .docx files
This node processes PDFs; for Word documents use the separate Replace Text With Image in Word Document node.

Cheat Sheet

FieldValue
ActionReplace Text With Image
PDF Input Data TypeBinary Data
PDF Binary Fielddata
Image Input Data TypeBinary Data
Image Binary Fielddata
Text to Replace[LOGO_HERE]
Page Sequenceall
Image Height50
Image Width100
Output File Namereplace_text_with_image.pdf
CredentialsPDF4me API credential

Common Questions

Does Text to Replace need to match exactly?+
Yes. PDF4me performs precise text matching, so Text to Replace must match the placeholder in the PDF exactly, including spaces, punctuation, and capitalization, similar to the exact-match requirements described in community discussions on replacing content inside a PDF.
Can I replace text on only some pages?+
Yes. Page Sequence accepts all, specific page numbers such as 1,3,5, or ranges such as 1-5, so you can target only the pages that contain the placeholder.
What image formats can replace the text?+
JPG, PNG, GIF, and BMP. Supply the image via Image Binary Field, Base64 Image Content, or Image URL depending on Image Input Data Type.
Does the image keep its aspect ratio?+
PDF4me scales the image to the Image Height and Image Width you specify while maintaining aspect ratio, so choose dimensions that match the source image's proportions, the same general scaling consideration covered in Adobe's guidance on placing graphics onto a PDF page.
Is this the same as the Word variant of this action?+
No. This action operates on PDF documents. A separate Replace Text With Image in Word Document node exists in n8n for .docx files, using Word-specific merge-field style placeholders instead of exact-text matching.

Same Task on Other Platforms

Get Help