Skip to main content

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.

Replace Text Power Automate

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

ParameterTypeDescriptionExample
Operation/docContent***Base64Source 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***StringWord 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

ParameterTypeDescriptionExample
Search Text***StringText 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 TextStringText 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 CaseBooleanCase-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 WordBooleanWhole 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 ExpressionsBooleanRegular 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 NameStringFont 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 ColorStringText 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 SizeNumber (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 ColorStringBackground 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"
BoldBooleanApply 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
ItalicBooleanApply 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
UnderlineBooleanApply 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
StrikethroughBooleanApply 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 StrikethroughBooleanApply 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
SubscriptBooleanApply 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
SuperscriptBooleanApply 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 SpacingNumber (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 View

Response data in a structured table format:

ParameterTypeDescription
documentBase64Word document with text replacements applied
SuccessBooleantrue if operation successful, false if failed
Error MessageStringError description (null if successful)
ErrorsArrayList of detailed error information (empty array if successful)

Common Error Messages

Understanding and troubleshooting errors helps ensure smooth text replacement workflows:

Error MessageCauseSolution
"Request is empty"Request object is nullProvide valid request object
"Document is empty"Document object is nullProvide valid Word document
"At least one phrase replacement is required"Text Replacements array is null or emptyProvide at least one replacement phrase in the array
"FindText cannot be empty in phrase replacement"Search Text is null or empty in a replacementProvide valid text to search for in each replacement
"Error replacing text"General exception during text replacementCheck document format and parameters. Review exception details in Errors array
"Error loading document from bytes"Invalid or corrupted Word documentVerify 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:

Automated Template Processing Workflow

Streamline your document generation with automated template processing:

Complete Workflow Steps:

  1. Trigger: Document template ready for processing in SharePoint
  2. Get Template: Retrieve Word template from templates library
  3. Replace Company Name: Replace "[COMPANY_NAME]" with "Acme Corporation"
  4. Replace Date: Replace "[DATE]" with current date
  5. Replace Contact Info: Replace "[CONTACT_EMAIL]" with "[email protected]"
  6. Set Formatting: Apply bold formatting to company name, red color to date
  7. Email Processed Document: Send processed document to stakeholders
  8. 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%

Industry Use Cases & Applications

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

Get Help