Skip to main content

Replace Text With Image In Word in n8n

Replace Text With Image In Word is a PDF4me node action in n8n that finds a text marker inside a .docx and puts an image in its place. Use it to drop a signature into a contract, a logo into a branded template, or a generated QR code into a shipping document, without any manual editing.

What this node does

This action takes two independent inputs: a Word document and an image, each with its own input-type dropdown. It searches the document for the exact string in Search Text and substitutes the image wherever that string appears on the pages you scope. The result is a new .docx with the picture embedded, ready for the next node.

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 document requests.

Important Facts You Should Not Miss

Two sources, two dropdowns
The Word file and the image are configured separately. Leaving the image source unset is the most common reason a run produces an unchanged document.
Search Text is the one hard requirement
It is the only field the node marks with a validation warning when empty. Everything else in the panel arrives with a usable default.
A silent zero is not an error
If the marker does not match, the node still succeeds and returns the original text. Gate on replacementsMade rather than on success.

Word mail merge vs Replace Text With Image: which should I use?

Word's native mail merge is built to substitute text. Placing a picture normally means nesting an INCLUDEPICTURE field inside a MERGEFIELD, pointing it at a stable file path, and refreshing fields before the images appear. That is workable on a desktop and awkward inside an automated pipeline. This node treats the placeholder as ordinary document text and swaps a real image in, so the file that leaves the workflow already has the picture embedded.

Word mail merge with INCLUDEPICTUREPDF4me Replace Text With Image
Image sourceA file path the field can reachBinary data, base64, or a URL
Field refreshOften needed before pictures renderNot applicable, the image is embedded
Runs unattendedFragile outside the desktop appDesigned for it
Per-page targetingNot built inPage Numbers plus first-page skip
Several markersOne merge passChain one node per marker
Which vs whichPick for desktop, one-off mergesPick for unattended workflow runs

How do I set up the node?

Add the PDF4me Replace Text With Image In Word action to your n8n workflow. For first-time setup, see the n8n Integration Guide.

Prerequisites: a PDF4me API credential, an n8n workflow, a .docx containing your marker text, and the image to insert.

The Replace Text With Image In Word parameter panel in n8n, showing separate input type dropdowns for the Word document and the image
The node panel. Note the two independent input-type dropdowns and the red validation border on the empty Search Text field.

What are the parameters?

Fields appear in the panel in the order below. Only Search Text is flagged as mandatory; the rest carry defaults or depend on which input mode you choose.

ParameterTypeRequiredDescriptionExample
Word Document Input TypeOptionsRequiredHow the .docx reaches the node: Binary Data, Base64 String, or URL. The matching source field appears directly beneath it.Binary Data
Word Document Binary PropertyStringConditionalName of the binary property holding the Word file. Shown when the input type is Binary Data.data
Base64 Word Document ContentStringConditionalThe .docx as a base64 string. Shown when the input type is Base64 String.UEsDBBQABgAI...
Word Document URLStringConditionalA publicly reachable link to the .docx. Shown when the input type is URL.https://example.com/contract.docx
Word Document NameStringOptionalFilename used for the document being processed. Ships with a placeholder default.document.docx
Image Input TypeOptionsRequiredHow the image reaches the node. This is a separate dropdown from the Word document and is set independently.Binary Data
Image Binary PropertyStringConditionalName of the binary property holding the image. Shown when the image input type is Binary Data.data
Base64 Image ContentStringConditionalThe image as a base64 string. Shown when the image input type is Base64 String.iVBORw0KGgoAAAANS...
Image URLStringConditionalA publicly reachable link to the image. Shown when the image input type is URL.https://example.com/logo.png
Image File NameStringOptionalFilename of the image being inserted. Ships with a placeholder default.image.png
Is First Page SkipToggleOptionalExcludes page one from the search. Ships switched off. Useful when a cover page or letterhead must stay untouched.off
Page NumbersStringOptionalPages to search. Accepts a single page, a comma list, or a hyphenated range. Ships with 1.1
Search TextStringRequiredThe exact marker string to find and replace. The node shows a validation warning while this is empty.[LOGO_PLACEHOLDER]
Output Binary Field NameStringOptionalProperty name the resulting .docx is written to for the next node. Ships with data.data
Page Numbers syntax

The field accepts a single page (3), a comma-separated list (1,4,7), a hyphenated range (2-6), or a mix of the two (1,3,5-8). Scope it to the pages that really contain the marker so a stray match elsewhere in a long document does not pick up an image.

What does the node return?

FieldTypeDescriptionExample
successBooleanWhether the operation completed. Note that a run which found no matches still returns true.true
messageStringHuman-readable status text, used for error detail when something fails.Text replaced with image successfully
fileNameStringFilename of the generated Word document.document_with_images.docx
mimeTypeStringMIME type of the output, always the .docx type.application/vnd.openxmlformats-officedocument.wordprocessingml.document
fileSizeNumberSize of the generated document in bytes.125430
docNameStringDocument name reference, matching fileName.document_with_images.docx
textReplacementCompletedBooleanConfirms the replacement pass ran to completion.true
replacementsMadeNumberHow many instances of the search text were substituted. This is the field to branch on.3

N8N Action Response

[
{
"success": true,
"message": "Text replaced with image successfully",
"fileName": "document_with_images.docx",
"mimeType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"fileSize": 125430,
"docName": "document_with_images.docx",
"textReplacementCompleted": true,
"replacementsMade": 3
}
]

Typical Setups

Signature on a contract
A signing step returns a signature PNG. Point Word Document Input Type at the contract from the previous node, Image Input Type at the signature binary, and set Search Text to your [SIGNATURE] marker.
Logo into a branded template
The template lives in storage and the logo at a fixed URL. Use Binary Data for the document and URL for the image, so the logo is not re-uploaded on every run.
QR code onto a shipping document
A code-generating node produces the image, this node substitutes it for [QR_HERE], and a converter turns the result into a PDF for the carrier.
Per-record images at scale
Loop over a spreadsheet, fetch each row image, and run one node execution per record to produce an individually illustrated document.

Practical Tips

  • Branch on replacementsMade, not success. A run that matches nothing still reports success. An IF node checking that the count is above zero catches a broken template before the document reaches a customer.
  • Type the marker once, then copy it. If part of a placeholder is retyped or restyled in Word, the program splits it into separate formatting runs internally and the search no longer sees one contiguous string, even though the page looks unchanged.
  • Pick markers that cannot occur naturally. Bracketed uppercase tokens such as [LOGO_PLACEHOLDER] will not collide with body copy the way a bare word like Logo can.
  • Chain nodes for multiple images. Feed each node's output document into the next node's input to accumulate a logo, a signature, and a QR code in one file.
  • Mind the placeholder's own formatting. The image lands where the text was, so a marker sitting in a centred, generously spaced paragraph generally produces a better result than one buried mid-sentence.
  • Prefer URL mode for static artwork. A company logo that never changes does not need to travel through the workflow as binary data on every execution.

Cheat Sheet

GoalSetting
Insert a signature imageSearch Text = your signature marker, image via Binary Data
Leave the cover page aloneIs First Page Skip on
Search only pages 2 to 5Page Numbers = 2-5
Use a hosted logoImage Input Type = URL, Image URL = the link
Detect a failed matchCheck replacementsMade equals 0
Feed the result onwardRead the property named in Output Binary Field Name

Common Questions

Why does Word mail merge struggle with images?

Word's built-in mail merge substitutes text. Getting a picture in traditionally means an INCLUDEPICTURE field nested with a MERGEFIELD, which requires the images to sit at stable file paths and often needs a manual field refresh before they appear. This node takes a different route: it treats the placeholder as ordinary text in the .docx and swaps an actual image in its place, so the merged document arrives with the picture already embedded.

Do the Word document and the image have to use the same input method?

No. Word Document Input Type and Image Input Type are two separate dropdowns configured independently. A common pattern is Binary Data for the .docx coming from a previous n8n node, and URL for a logo that lives at a fixed address, which avoids fetching the same image on every run.

What happens if the search text is not found?

The action completes and returns a document, but nothing is substituted. Check replacementsMade in the response: a value of 0 means the marker never matched. The usual cause is Word having split the placeholder across internal formatting runs, which happens when part of the marker was retyped or restyled, so it no longer exists as one contiguous string even though it looks correct on screen.

Can one run replace several different placeholders?

One execution handles one Search Text value paired with one image. A template that needs a logo, a signature, and a QR code is handled by chaining three of these nodes, each feeding its output document into the next one's input, so the substitutions accumulate in a single file.

Which fields are actually required?

Search Text is the only field the node flags as mandatory. Word Document Name, Image File Name, Page Numbers, and Output Binary Field Name all ship with working defaults, and the two input-type dropdowns each require whichever source field matches the mode you picked.

How do I keep a cover page from being changed?

Turn on the Is First Page Skip toggle, which ships off. It excludes page one from the search, which is useful when a letterhead or title page happens to contain the same wording as the marker you are targeting elsewhere in the document.

Same Task on Other Platforms

Use Cases

Document branding and visual identity

Replace placeholder tokens with company logos or product images so every document a workflow produces carries consistent branding, without anyone opening Word.

Signatures and authentication marks

Drop signature images, stamps, or seals into contracts and approval forms at the point the workflow reaches them, keeping the signing step inside the automation.

Generated artwork per record

Insert QR codes, barcodes, or charts that were produced earlier in the same workflow, which is how a batch of shipping documents or personalised reports ends up individually illustrated.

Further Reading

Get Help