Skip to main content

Replace Text in Word Document using n8n action

PDF4me Replace Text in Word Document enables finding and replacing text in Word documents through n8n automation workflows with advanced formatting options and comprehensive text styling capabilities. This powerful text replacement feature supports multiple replacement phrases, case-sensitive matching, whole word matching, regular expressions, and detailed formatting control with full control over font properties, colors, text effects, and positioning, perfect for document automation, template processing, and content management workflows.

Setup

Add the PDF4me "Replace Text 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 in Word Document" action
  3. Configure input parameters (see below)
Replace Text in Word Document

Parameters

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

Important: Parameters marked with an asterisk (***) are required. The Text Replacements array must contain at least one replacement phrase.

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
Text Replacements***ArrayArray of Text Replacement Objects
• Array of text replacement objects, must contain at least one replacement phrase
• Each replacement object contains: Search Text (required), Replacement Text (optional), Match Case, Match Whole Word, Use Regular Expressions, and font formatting options
[{"SearchText": "old text", "ReplacementText": "new text"}]

Text Replacement Object Properties:

PropertyTypeDescriptionExample
SearchText***StringText to search for - Text string to search for in the document. Cannot be null or empty"old text"
ReplacementTextStringText to replace with - Text to replace the found text with. Can be empty string to remove found text"new text"
MatchCaseBooleanCase-sensitive matching - True for case-sensitive search, False for case-insensitive (default: false)false
MatchWholeWordBooleanWhole word matching - True to match only complete words, False for partial matches (default: false)false
UseRegularExpressionsBooleanRegular expression support - True to treat SearchText as regex pattern, False for literal text (default: false)false
FontNameStringFont family - Font family to apply to replacement text (e.g., "Arial", "Times New Roman")"Arial"
FontColorStringText color - Named colors, hex format, or RGB format (e.g., "Red", "#FF0000", "RGB(255,0,0)")"Red"
FontSizeNumberFont size in points - Font size for replacement text (e.g., 10, 12, 14, 16)14
BackgroundColorStringBackground color - Background color for replacement text (e.g., "Yellow", "#FFFF00")"Yellow"
BoldBooleanApply bold formatting - True to apply bold, False for no bold (default: false)false
ItalicBooleanApply italic formatting - True to apply italic, False for no italic (default: false)false
UnderlineBooleanApply underline formatting - True to apply underline, False for no underline (default: false)false
StrikethroughBooleanApply strikethrough - True to apply single strikethrough, False for no strikethrough (default: false)false
DoubleStrikethroughBooleanApply double strikethrough - True to apply double strikethrough, False for no double strikethrough (default: false)false
SubscriptBooleanApply subscript formatting - True to apply subscript, False for no subscript (default: false)false
SuperscriptBooleanApply superscript formatting - True to apply superscript, False for no superscript (default: false)false
WordSpacingNumberWord spacing in points - Spacing between words (default: 0)0

Output

Output Parameters

ParameterTypeDescriptionExample
fileNameStringWord document filename with text replaced - The name of the output Word document file after text replacementdocument_text_replaced.docx
fileSizeNumberFile size in bytes - The size of the Word document in bytes after text replacement13370
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
phrasesCountNumberNumber of replacement phrases - The total count of text replacement phrases that were processed1
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 replacement operationText replaced successfully

N8N Action Response

The PDF4me Replace Text 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.docx",
"fileSize": 13370,
"success": true,
"originalFileName": "document.docx",
"phrasesCount": 1,
"cultureName": "en-US",
"message": "Text replaced successfully"
}
]

Use Cases

Enterprise Document Automation

  • Document Automation: Replace placeholder text with dynamic content
  • Template Processing: Update template variables with actual values
  • Content Management: Standardize terminology and formatting
  • Document Personalization: Insert personalized information into documents

AI-Powered Document Processing

  • Multi-Format Support: Process Word documents in .docx and .doc formats
  • Multi-Language Processing: Extract data from documents in various languages
  • Intelligent Field Recognition: Automatically identify and replace text patterns

Business Intelligence and Analytics

  • Content Standardization: Ensure consistent terminology across documents
  • Compliance Monitoring: Update documents to meet regulatory requirements
  • Performance Metrics: Track processing accuracy and efficiency

Get Help