Skip to main content

Replace Text with Image in Word using Power Automate

PDF4me Replace Text with Image action enables replacing specified text with images in Word documents in Power Automate 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 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 with Image Power Automate

Key Features

  • Text-to-Image Replacement: Replace specific text strings with images throughout documents
  • Precise Text Matching: Case-sensitive text search and replacement
  • Image Size Control: Customize image dimensions with width and height parameters
  • Aspect Ratio Preservation: Maintain image proportions during resizing
  • Page Filtering: Target specific pages or page ranges for replacement
  • Advanced Filtering: Skip first page, target odd/even pages, or specify exact page numbers
  • Multiple Image Formats: Support for PNG, JPG, JPEG, BMP, GIF formats
  • Flexible Positioning: Insert images as Word shapes with precise positioning

Parameters

Complete list of parameters for the Replace Text with Image 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
File Content***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
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
• Examples: "[LOGO]", "SIGN_HERE", "[SIGNATURE]"
"SIGN_HERE"
Image Content***Base64Replacement Image Content
• Base64-encoded content of the image file
• Map image file from previous action output or file upload
• Supports image files from SharePoint, OneDrive, email attachments
• Can be dynamically retrieved from flow variables
• Direct base64 can be given in the file content also
• Must be valid image file (PNG, JPG, JPEG, BMP, GIF formats)
[File Content from Get File]
Image WidthNumber (double)Image Width in Points
• Width of the replacement image in points
• Optional - if not specified, uses original image width
• Must be positive value
• If only Width specified, Height calculated to maintain aspect ratio
• Used with Height for precise sizing control
• Image sizing behavior: Width only = calculates height to maintain aspect ratio
200
Image HeightNumber (double)Image Height in Points
• Height of the replacement image in points
• Optional - if not specified, uses original image height
• Must be positive value
• If only Height specified, Width calculated to maintain aspect ratio
• Used with Width for precise sizing control
• Image sizing behavior: Height only = calculates width to maintain aspect ratio
150
Maintain Aspect RatioBooleanPreserve Image Proportions
Yes - Maintains original image aspect ratio when resizing
No - Uses exact width and height values (may distort image)
• Default: Yes
• When Yes, one dimension is calculated to preserve proportions
• When No, both dimensions are used exactly as specified
• Image sizing behavior: Both dimensions + MaintainAspectRatio = Yes = calculates one dimension to preserve proportions
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
• Useful when first page is a cover page or title page
• Applied before other page filtering options
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
• Advanced parameter for precise page targeting
• Page filtering order: Apply To Pages → Page Numbers → Skip First Page → Ignore Page Numbers
"all"
Page NumbersStringSpecific Page Numbers or Ranges
• Comma-separated page numbers or ranges (e.g., "1,3,5-7")
• Advanced parameter for targeting specific pages
• Can be used with Apply To Pages for combined filtering
• Examples: "1,3,5", "2-4,6,8-10"
• Invalid page numbers are silently ignored
• Example: Apply To Pages = "odd" + Page Numbers = "1,3,5-7" = Pages 1, 3, 5, 7
"1,3,5-7"
Ignore Page NumbersStringPage Numbers to Skip
• Comma-separated page numbers to exclude from processing
• Advanced parameter for excluding specific pages
• Applied after other page filtering options
• Examples: "2,4", "1,3,5"
• Useful for excluding cover pages or specific sections
• Example: Apply To Pages = "all" + Ignore Page Numbers = "2,4" = All pages except 2 and 4
"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)
• Affects document language and formatting
• Use valid culture codes for international documents
• Used for metadata and localization handling
en-US

Output

The PDF4me Replace Text with Image 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 replaced by images
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
"FindText is required for text replacement"Search Text is null or emptyProvide valid text to search for
"Image content is required"Image Content is null or emptyProvide valid base64-encoded image content
"Error replacing text with image"General exception during text replacementCheck document format, image 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)
"No pages match the filtering criteria"Page filtering resulted in no pages to processAdjust page filtering parameters
"Invalid culture name provided. Skipping metadata."Invalid culture/locale code providedUse valid culture codes (e.g., en-US, fr-FR, de-DE)

Workflow Examples

The PDF4me Replace Text with Image 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. Get Company Logo: Retrieve company logo image from assets
  4. Replace Logo Placeholder: Replace "[LOGO]" text with company logo
  5. Set Parameters: Search Text = "[LOGO]", Image Width = 200, Maintain Aspect Ratio = Yes
  6. Skip First Page: Skip First Page = No (include cover page)
  7. Email Processed Document: Send processed document to stakeholders
  8. Archive Template: Store processed document in completed templates folder

Business Benefits:

  • Processes 100+ document templates monthly automatically
  • Replaces placeholder text with company branding
  • Ensures consistent logo placement and sizing
  • Reduces manual template processing time by 90%

Image Sizing Examples

Understanding image sizing behavior helps optimize your text replacement workflows:

WidthHeightMaintain Aspect RatioResult
200nullYesWidth=200, Height=calculated to preserve proportions
null150YesWidth=calculated to preserve proportions, Height=150
200100YesWidth=200, Height=100 (aspect ratio maintained)
200100NoWidth=200, Height=100 (exact dimensions, may distort)
nullnullYesOriginal image dimensions preserved

Supported Image Formats

The Replace Text with Image action supports various image formats for maximum compatibility:

FormatExtensionDescription
PNG.pngPortable Network Graphics - best for logos and graphics with transparency
JPEG.jpg, .jpegJoint Photographic Experts Group - best for photographs and complex images
BMP.bmpBitmap - uncompressed format, larger file sizes
GIF.gifGraphics Interchange Format - supports animation and transparency

Industry Use Cases & Applications

Legal & Professional Services Use Cases

  • Contract Processing: Replace signature placeholders with authorized signatures
  • Legal Document Automation: Insert firm logos and watermarks into legal documents
  • Client Document Personalization: Add client-specific images to legal documents
  • Compliance Documentation: Insert compliance stamps and seals into documents

Get Help