Replace Text in Power Automate
PDF4me Replace Text action enables finding and replacing text in Word documents in Power Automate 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 across Microsoft 365.
Authenticating Your API Request
To access the PDF4me Web API through Power Automate, every request must include proper authentication credentials. Authentication ensures secure communication and validates your identity as an authorized user, enabling seamless integration between your Power Automate flows and PDF4me's powerful Word text replacement services.

Key Features
- Multiple Text Replacements: Perform multiple find and replace operations in a single action
- Advanced Search Options: Case-sensitive matching, whole word matching, and regular expressions
- Comprehensive Formatting: Full control over font, size, color, and text effects
- Pattern Matching: Support for regular expressions with complex text patterns
- Text Styling: Bold, italic, underline, strikethrough, subscript, and superscript
- Color Control: Text color and background color with multiple color formats
- Sequential Processing: Multiple replacements processed in specified order
- Flexible Matching: Exact matches, partial matches, or whole word matches
Parameters
Complete list of parameters for the Replace Text 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.
Document Input Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| Operation/docContent*** | Base64 | Source Word File Content • Map Word file from previous action output • Supports Word files from SharePoint, Dropbox, OneDrive, email attachments • Can be dynamically retrieved from flow variables • Direct base64 can be given in the file content also • Must be valid Word document (.docx, .doc formats) • Text replacement is performed on this document | [File Content from Get File] |
| File Name*** | String | Word Document Name • Specify Word file name with extension (.docx, .doc) • Used for processing and output file naming • Must include proper file extension • Supports dynamic naming from flow variables • Output filename matches input filename | document.docx |
Text Replacements Array
| Parameter | Type | Description | Example |
|---|---|---|---|
| Search Text*** | String | Text to Search For • Text string to search for in the document • Cannot be null or empty • Case-sensitive or case-insensitive based on Match Case setting • Supports regular expressions when Use Regular Expressions is enabled • All instances of this text will be replaced | "old text" |
| Replacement Text | String | Text to Replace With • Text to replace the found text with • Can be empty string to remove found text • Supports regular expression substitutions when using regex • Formatting is applied to this replacement text • Default: empty string (removes found text) | "new text" |
| Match Case | Boolean | Case-Sensitive Matching • True - Search is case-sensitive (exact case match required) • False - Search is case-insensitive (default) • Controls whether "The" matches "the" or only "The" • Useful for precise text matching | False |
| Match Whole Word | Boolean | Whole Word Matching • True - Match only complete words (not partial matches) • False - Match partial text within words (default) • Prevents "the" from matching "there" or "other" • Useful for precise word replacement | False |
| Use Regular Expressions | Boolean | Regular Expression Support • True - Search Text is treated as a regular expression pattern • False - Search Text is treated as literal text (default) • Enables complex pattern matching and substitutions • Supports standard regex syntax | False |
| Font Name | String | Font Family • Font family to apply to replacement text • Common fonts: "Arial", "Times New Roman", "Calibri" • Default: null (preserves existing font) • Applied to all replacement text instances • Invalid fonts may use system default | "Arial" |
| Font Color | String | Text Color • Named colors: "Red", "Blue", "Green", "Black" • Hex format: "#FF0000", "#00FF00", "FF0000" (with or without #) • RGB format: "RGB(255, 0, 0)" or "rgb(255,0,0)" • 3-digit hex: "#F00" expands to "#FF0000" • Default: null (preserves existing color) | "Red" |
| Font Size | Number (double) | Font Size in Points • Font size for replacement text in points • Must be positive value • Common sizes: 10, 12, 14, 16, 18, 24 • Default: null (preserves existing size) • Applied to all replacement text instances | 14 |
| Background Color | String | Background Color of Replacement Text • Named colors: "Yellow", "Green", "Blue", "Red", "Gray" • Hex format: "#FFFF00", "#00FF00", "FFFF00" (with or without #) • RGB format: "RGB(255, 255, 0)" or "rgb(255,255,0)" • 3-digit hex: "#FF0" expands to "#FFFF00" • Default: null (no background color) • Applied as highlight color to replacement text | "Yellow" |
| Bold | Boolean | Apply Bold Formatting • True - Apply bold formatting to replacement text • False - No bold formatting (default) • Makes replacement text appear in bold font weight • Applied to all replacement text instances | False |
| Italic | Boolean | Apply Italic Formatting • True - Apply italic formatting to replacement text • False - No italic formatting (default) • Makes replacement text appear in italic style • Applied to all replacement text instances | False |
| Underline | Boolean | Apply Underline Formatting • True - Apply underline formatting to replacement text • False - No underline formatting (default) • Adds underline to replacement text • Applied to all replacement text instances | False |
| Strikethrough | Boolean | Apply Single Strikethrough • True - Apply single strikethrough to replacement text • False - No strikethrough formatting (default) • Adds single line through replacement text • Applied to all replacement text instances | False |
| Double Strikethrough | Boolean | Apply Double Strikethrough • True - Apply double strikethrough to replacement text • False - No double strikethrough formatting (default) • Adds double line through replacement text • Applied to all replacement text instances | False |
| Subscript | Boolean | Apply Subscript Formatting • True - Apply subscript formatting to replacement text • False - No subscript formatting (default) • Makes replacement text appear as subscript • Applied to all replacement text instances | False |
| Superscript | Boolean | Apply Superscript Formatting • True - Apply superscript formatting to replacement text • False - No superscript formatting (default) • Makes replacement text appear as superscript • Applied to all replacement text instances | False |
| Word Spacing | Number (double) | Spacing Between Words in Points • Spacing between words in replacement text • Default: 0 (normal word spacing) • Positive values increase spacing, negative values decrease spacing • Measured in points • Applied to all replacement text instances | 0 |
Text Replacements Array Structure:
- Each replacement is processed sequentially in the order specified
- Multiple replacements can be performed on the same document
- Each replacement can have different formatting options
- All instances of Search Text are replaced (unless using whole word matching)
Output
The PDF4me Replace Text action returns comprehensive output data for seamless Power Automate flow integration:
- Table
- JSON
- Flow Integration
Table View
Response data in a structured table format:
| Parameter | Type | Description |
|---|---|---|
| document | Base64 | Word document with text replacements applied |
| Success | Boolean | true if operation successful, false if failed |
| Error Message | String | Error description (null if successful) |
| Errors | Array | List of detailed error information (empty array if successful) |
JSON Response Format
The raw JSON response from the action:
{
"document": "[Base64 Word Content with Text Replacements]",
"Success": true,
"ErrorMessage": null,
"Errors": []
}
Error Response Example:
{
"document": null,
"Success": false,
"ErrorMessage": "At least one phrase replacement is required",
"Errors": [
{
"Code": "VALIDATION_ERROR",
"Message": "Text Replacements array cannot be null or empty"
}
]
}
Power Automate Flow Usage
Use documents with replaced text in subsequent actions:
- 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
- Report Generation: Update report data and formatting
- Email Distribution: Send processed documents to stakeholders
Common Error Messages
Understanding and troubleshooting errors helps ensure smooth text replacement workflows:
| Error Message | Cause | Solution |
|---|---|---|
| "Request is empty" | Request object is null | Provide valid request object |
| "Document is empty" | Document object is null | Provide valid Word document |
| "At least one phrase replacement is required" | Text Replacements array is null or empty | Provide at least one replacement phrase in the array |
| "FindText cannot be empty in phrase replacement" | Search Text is null or empty in a replacement | Provide valid text to search for in each replacement |
| "Error replacing text" | General exception during text replacement | Check document format and parameters. Review exception details in Errors array |
| "Error loading document from bytes" | Invalid or corrupted Word document | Verify the input document is a valid Word file (.docx) |
Workflow Examples
The PDF4me Replace Text action in Power Automate provides comprehensive workflow templates designed for real-world business scenarios:
- Template Processing
- Content Standardization
- Report Generation
- Document Personalization
Automated Template Processing Workflow
Streamline your document generation with automated template processing:
Complete Workflow Steps:
- Trigger: Document template ready for processing in SharePoint
- Get Template: Retrieve Word template from templates library
- Replace Company Name: Replace "[COMPANY_NAME]" with "Acme Corporation"
- Replace Date: Replace "[DATE]" with current date
- Replace Contact Info: Replace "[CONTACT_EMAIL]" with "[email protected]"
- Set Formatting: Apply bold formatting to company name, red color to date
- Email Processed Document: Send processed document to stakeholders
- Archive Template: Store processed document in completed templates folder
Business Benefits:
- Processes 200+ document templates monthly automatically
- Replaces placeholder text with actual company information
- Ensures consistent formatting and branding
- Reduces manual template processing time by 95%
Automated Content Standardization Workflow
Enhance your document consistency with automated content standardization:
Complete Workflow Steps:
- Trigger: Document uploaded to SharePoint for standardization
- Get Document: Retrieve Word document from upload location
- Standardize Terminology: Replace "do we use it" with "Pdf4me"
- Update Branding: Replace old company names with current branding
- Format Headers: Apply consistent header formatting (Arial, 16pt, Bold)
- Color Code Sections: Apply red color to important sections
- Email Standardized Document: Send standardized document to team
- Archive Document: Store standardized document in approved library
Business Benefits:
- Standardizes 300+ documents monthly automatically
- Ensures consistent terminology and branding
- Applies uniform formatting across all documents
- Reduces manual content review time by 90%
Automated Report Generation Workflow
Optimize your reporting with automated report data replacement:
Complete Workflow Steps:
- Trigger: Report template ready for data population
- Get Report Template: Retrieve Word report template from templates library
- Replace Metrics: Replace "[TOTAL_SALES]" with actual sales data
- Replace Dates: Replace "[REPORT_DATE]" with current date
- Replace Performance: Replace "[PERFORMANCE_RATING]" with calculated rating
- Format Data: Apply bold formatting to metrics, blue color to dates
- Email Report: Send populated report to management team
- Archive Report: Store final report in reports library
Business Benefits:
- Generates 50+ reports monthly automatically
- Replaces template data with actual business metrics
- Ensures consistent report formatting and presentation
- Reduces manual report generation time by 85%
Automated Document Personalization Workflow
Enhance your client communication with automated document personalization:
Complete Workflow Steps:
- Trigger: Client document ready for personalization
- Get Document: Retrieve Word document from client queue
- Replace Client Name: Replace "[CLIENT_NAME]" with actual client name
- Replace Project Info: Replace "[PROJECT_NAME]" with project details
- Replace Contact: Replace "[ACCOUNT_MANAGER]" with assigned manager
- Format Personal Info: Apply blue color to client name, bold to project info
- Email Client: Send personalized document to client
- Archive Personal: Store personalized document in client folder
Business Benefits:
- Personalizes 150+ client documents monthly automatically
- Replaces placeholder text with client-specific information
- Ensures professional document presentation
- Reduces manual document personalization time by 80%
Industry Use Cases & Applications
- Legal & Professional Services
- Finance & Accounting
- Sales & Marketing
- Human Resources
- Healthcare & Medical
- Education & Research
Legal & Professional Services Use Cases
- Contract Processing: Replace placeholder text with client-specific information
- Legal Document Automation: Update case numbers, client names, and dates
- Template Standardization: Standardize legal terminology and formatting
- Client Communication: Personalize legal documents for specific clients
Finance & Accounting Use Cases
- Financial Report Generation: Replace template data with actual financial metrics
- Invoice Processing: Update invoice templates with client and payment information
- Budget Document Automation: Replace budget placeholders with actual figures
- Audit Report Generation: Update audit templates with specific audit findings
Sales & Marketing Use Cases
- Proposal Generation: Replace proposal templates with client-specific information
- Marketing Material Creation: Update marketing templates with campaign details
- Client Communication: Personalize sales documents for specific prospects
- Report Standardization: Standardize sales terminology and formatting
Human Resources Use Cases
- Employee Document Processing: Replace HR templates with employee-specific information
- Policy Document Updates: Update policy templates with current policy information
- Training Material Creation: Replace training templates with specific training content
- Compliance Documentation: Update compliance templates with current requirements
Healthcare & Medical Use Cases
- Medical Report Generation: Replace medical templates with patient-specific information
- Patient Communication: Personalize medical documents for specific patients
- Research Documentation: Update research templates with study-specific data
- Compliance Documentation: Update medical compliance templates with current standards
Education & Research Use Cases
- Academic Paper Generation: Replace research templates with study-specific information
- Curriculum Document Creation: Update curriculum templates with specific course content
- Student Communication: Personalize educational documents for specific students
- Research Report Generation: Update research templates with study findings