Skip to main content

Replace Text With Image in Word Document using n8n action

PDF4me Replace Text With Image in Word Document enables replacing specified text with images in Word documents through n8n automation workflows with advanced page filtering and size control options. This powerful text replacement feature supports precise text matching, image insertion, customizable sizing with aspect ratio preservation, page-specific targeting, and flexible filtering options with full control over replacement behavior, perfect for document automation, template processing, and dynamic content insertion workflows.

Setup

Add the PDF4me "Replace Text With Image in Word Document" node to your n8n workflow and configure the required parameters. For initial setup instructions, see our n8n Integration Guide.

Prerequisites:

  • PDF4me API credentials
  • n8n workflow access

Configuration:

  1. Add PDF4me node to workflow
  2. Select "Replace Text With Image in Word Document" action
  3. Configure input parameters (see below)
Replace Text With Image in Word Document

Parameters

Complete list of parameters for the Replace Text With Image in Word Document action. Configure these parameters to control text replacement behavior.

Important: Parameters marked with an asterisk (***) are required. Advanced parameters provide fine-grained control over image sizing and page filtering.

ParameterTypeDescriptionExample
Input Data Type***StringWord Document Input Format Selection
• Choose the format of your Word document data input
• PDF4me supports multiple input types
• Options: Binary Data, Base64 String, or URL
Binary Data
Input Binary Field***BinaryBinary Word File Input (Required if Binary Data)
• Reference Word file (.docx, .doc) from previous n8n node or file upload
• PDF4me processes binary Word files with automatic format detection
• Required when Input Data Type is "Binary Data"
{{ $binary.data }}
Base64 Word Content***StringBase64 Encoded Word Input (Required if Base64 String)
• Provide Word content (.docx, .doc) as base64 encoded string for secure transmission
• PDF4me automatically decodes and processes the Word content
• Required when Input Data Type is "Base64 String"
UEsDBBQABgAI...
Word Document URL***StringPublic Word Document URL Input (Required if URL)
• Provide a public/open permission URL to the Word file (.docx, .doc) to be processed
• PDF4me downloads and processes the Word file from the provided URL
• Required when Input Data Type is "URL"
https://abc.com/document.docx
Word Document Name***StringWord Document Input Filename
• Specify the name of the input Word file with proper extension (.docx, .doc)
• PDF4me uses this for format detection and processing optimization
document.docx
Search Text***StringText to Search and Replace
• Text string to search for in the document
• Case-sensitive text matching
• All instances of this text will be replaced with the image
• Cannot be null or empty
"SIGN_HERE"
Image Content***Base64Replacement Image Content
• Base64-encoded content of the image file
• Must be valid image file (PNG, JPG, JPEG, BMP, GIF formats)
iVBORw0KGgoAAAANSUhEUg...
Image WidthNumberImage Width in Points
• Width of the replacement image in points
• Optional - if not specified, uses original image width
• If only Width specified, Height calculated to maintain aspect ratio
200
Image HeightNumberImage Height in Points
• Height of the replacement image in points
• Optional - if not specified, uses original image height
• If only Height specified, Width calculated to maintain aspect ratio
150
Maintain Aspect RatioBooleanPreserve Image Proportions
• Yes - Maintains original image aspect ratio when resizing (default)
• No - Uses exact width and height values (may distort image)
Yes
Skip First PageBooleanSkip Replacement on First Page
• Yes - Skip text replacement on the first page
• No - Include first page in replacement process (default)
No
Apply To PagesStringApply Replacement to Specific Page Types
• all - Apply to all pages (default)
• odd - Apply only to odd-numbered pages
• even - Apply only to even-numbered pages
• first - Apply only to the first page
• last - Apply only to the last page
"all"
Page NumbersStringSpecific Page Numbers or Ranges
• Comma-separated page numbers or ranges (e.g., "1,3,5-7")
• Can be used with Apply To Pages for combined filtering
"1,3,5-7"
Ignore Page NumbersStringPage Numbers to Skip
• Comma-separated page numbers to exclude from processing
• Applied after other page filtering options
"2,4"
Culture NameStringDocument Culture/Locale
• Culture code for document processing (e.g., "en-US", "fr-FR", "de-DE")
• Default: null (no culture-specific processing)
en-US

Output

Output Parameters

ParameterTypeDescriptionExample
fileNameStringWord document filename with text replaced by image - The name of the output Word document file after text-to-image replacementdocument_text_replaced_with_image.docx
fileSizeNumberFile size in bytes - The size of the Word document in bytes after text-to-image replacement14070
successBooleanPDF4me operation status - Boolean flag indicating the success or failure of the text replacement operation. PDF4me returns true for successful operations and false for any errorstrue
originalFileNameStringOriginal Word document filename - The name of the input Word document filedocument.docx
findTextStringSearch text used - The text string that was searched for and replaced with the imagePDF4me
maintainAspectRatioBooleanAspect ratio preservation status - Indicates whether the image aspect ratio was maintained during replacement. true if aspect ratio was preserved, false if exact dimensions were usedtrue
skipFirstPageBooleanFirst page skip status - Indicates whether the first page was skipped during replacement. true if first page was skipped, false if first page was includedfalse
applyToStringPage filter applied - The page filter that was applied during replacement. Values: "all", "odd", "even", "first", "last"all
cultureNameStringCulture/Locale code - Culture code used for document processing (e.g., "en-US", "de-DE", "fr-FR")en-US
messageStringOperation message - Descriptive message indicating the result of the text-to-image replacement operationText replaced with image successfully

N8N Action Response

The PDF4me Replace Text With Image in Word Document API returns a response that can be viewed in multiple formats. Choose the view that best fits your needs:

JSON Response Format

The raw JSON response from the API:

[
{
"fileName": "document_text_replaced_with_image.docx",
"fileSize": 14070,
"success": true,
"originalFileName": "document.docx",
"findText": "PDF4me",
"maintainAspectRatio": true,
"skipFirstPage": false,
"applyTo": "all",
"cultureName": "en-US",
"message": "Text replaced with image successfully"
}
]

Use Cases

Enterprise Document Automation

  • Document Automation: Replace placeholder text with dynamic images
  • Template Processing: Insert logos, signatures, or charts into templates
  • Document Personalization: Add personalized images to documents
  • Report Generation: Insert charts and graphs into reports

AI-Powered Document Processing

  • Multi-Format Support: Process Word documents in .docx and .doc formats
  • Multi-Language Processing: Support for different languages and regions
  • Intelligent Image Insertion: Automatic image sizing and positioning

Business Intelligence and Analytics

  • Document Management: Organize documents with proper image placement
  • Compliance Monitoring: Ensure documents meet formatting requirements
  • Performance Metrics: Track processing accuracy and efficiency

Get Help