The 'Search and Replace Text' flow action provides the capability to search for text fragments within Microsoft Word and PDF documents and replace with alternative text.
To redact text as opposed to replacing text with alternative text, review the 'Redact PDF' article.
Please refer to the following article showcasing the 'Search and Replace Text' Power Automate action: Populate a Word or PDF Document using Power Automate
The default 'Search and Replace Text' flow action parameters are detailed below:
- File Type: The type of file to process (DOCX or PDF)
- Filename: The PDF filename (including file extension)
- File Content: A Base64 encoded representation of the PDF file to be processed.
- Phrases: An array of phrases (See below for further details)
For each phrase; the 'Search Text' value will be replaced with the 'Replacement Text' value. By default; Text fragments are located by finding matching instances of the 'Search Text' parameter, to use a regular expression search simply set the 'Is Expression' value to true so that the 'Search Text' parameter will be treated as a regular expression and not a free text search.
Multiple phrases can be included within a single operation. To add more than one phrase click the 'Add new item' button:
- Search Text: The text or expression to use to locate matching text fragments.
- Is Expression: Set whether the 'Search Text' parameter should be treated as free text or regular expression.
- Replacement Text: The text which should be used to replace the text fragments with.
- Font: Specify the name of the font, if the font cannot be found the default 'Arial' font will be used
- Font Colour: Set the HTML colour of the font, the default colour is set to '#000000'
- Font Size: Set the HTML colour of the font, the default colour is set to '#000000'
- Background Colour: Set the HTML colour of the font background, the default colour is set to '#FFFFFF'
- Underline: Set whether the font should be underlined.
- Word Spacing: Set the word spacing value in pts.
- Line Spacing: Set the line spacing value in pts.
Currently only standard Windows fonts are supported, custom font support will be available from Q1 2022. Please refer to the following article to explore standard Windows fonts: Windows 10 Font List
Carriage Returns / Line Breaks / Section Breaks
You can use metacharacters in the 'Replacement Text' field to include &p for a paragraph break, &b for a section break, &m for a page break, and &l for a line break.
Inserts the following;
We recommend using the https://regexr.com/ site for regular expression creation and testing.
Please refer to the Obtaining the 'File Contents' Parameter article for guidance on how to obtain the 'File Content' parameter ready to provide to an Encodian flow action.
The advanced 'Search and Replace' flow action parameters are detailed below:
- Operation ID: (Advanced) The ID of a parent operation, please refer to: Flow Action Return Options: File Content vs. Operation ID
- Final Operation: (Advanced) Sets whether the this is last Encodian flow action, please refer to: Flow Action Return Options: File Content vs. Operation ID
The 'Search and Replace Text' flow action returns the following data.
Standard Return Values
- Filename - The filename of the document.
- FileContent - The processed PDF document content.
- OperationId - The unique ID assigned to this operation.
- HttpStatusCode - The HTTP Status code for the response.
- HttpStatusMessage - The HTTP Status message for the response.
- Errors - An array of error messages should an error occur.
- Operation Status - Indicates whether the operation has completed, has been queued or has failed.