Nutrient Document Converter includes a pattern-based redaction action that enables you to precisely control what content gets redacted from PDF documents. By defining specific text patterns or regular expressions (regex), you can ensure sensitive information is consistently removed across all your documents.

This guide explains how to implement pattern-based redaction in your Power Automate flows. This method is ideal when you know exactly what formats to redact, such as Social Security numbers, credit card numbers, or specific terms and phrases.

For automatic detection of sensitive information without defining patterns, refer to the AI-powered redaction guide.

At a high level, your flow will look similar to what’s shown below.

Pattern-based redaction using Power Automate

Common redaction patterns

The following examples show commonly used patterns for redacting sensitive information.

Social Security numbers (SSNs)

\b\d{3}-\d{2}-\d{4}\b

Matches: 123-45-6789

Credit card numbers

\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b

Matches: 1234-5678-9012-3456, 1234 5678 9012 3456

Email addresses

\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b

Matches: user@example.com

Phone numbers

\b(?:\d{3}[-.]?)?\d{3}[-.]?\d{4}\b

Matches: 555-123-4567, (555) 123-4567, 5551234567

Dates

\b\d{1,2}[/-]\d{1,2}[/-]\d{2,4}\b

Matches: 12/31/2023, 12-31-23

Creating a flow in Power Automate

To create a Power Automate flow that uses pattern-based redaction, follow the steps in this section.

First, create a manual trigger instant flow.

Create a flow in Power Automate

Then, add the Get file content step.

Create a flow in Power Automate

In the action, specify the path to the SharePoint Online site and relative URL of file. This action retrieves the PDF file content so it can be processed by the pattern redaction action.

Applying pattern-based redaction

Add the Nutrient Redact using patterns or regex action to Power Automate and configure it according to the details below.

Pattern-based redaction action

In the example above, the regex pattern detects numeric values, including those embedded within alphanumeric strings or formatted with commas, decimals, or hyphens.

Required fields

The required fields to configure the action are:

  • Source file name — Include the file name with its extension.
  • Source file content — Enter File Content, which is the output of the Get file content action.
  • Redaction type — Choose between regex or pattern
  • Redact pattern — Define your patterns:
    • Exact text — Match specific text strings (for example, "CONFIDENTIAL")
    • Regular expression — Use regex for flexible pattern matching

Additional settings

If needed, configure the following additional settings:

  • Case sensitive — Enable if the pattern should match case (Yes/No). The default is No.
  • Include annotations — Specify whether to include existing annotations in the redacted output. When enabled, annotations from the source PDF will be preserved in the redacted document.
  • Page range — Define specific pages to apply redaction to. Leave this empty to process all pages, or specify a range (for example, "1–5, 8, 10–12") to redact only selected pages. This is useful for processing large documents where only certain sections contain sensitive information.
  • Open password — Enter the password if the source PDF is password protected. This enables the action to open and process encrypted PDFs. Note that the redacted output PDF won’t be password protected, so you may need to apply encryption separately if required.
  • Fail on error — Determine how the action should handle errors during redaction. When this is enabled, the flow will stop and report an error if redaction fails. When this is disabled, the flow will continue even if redaction encounters issues, enabling you to implement custom error handling logic.

Saving the redacted PDF

Add the Create file SharePoint action to store the redacted PDF document in the library.

Create redacted file

Configure the action as follows:

  • Site address — Select the destination SharePoint site.
  • Folder path — Specify where to save the redacted PDF — for example, /Shared Documents/Redacted
  • File name — Use dynamic content to create the file name:
    Base file name_pattern_redact.pdf
  • File content — Enter Processed file content, which is the output variable of the Redact PDF with Patterns action.

Successful flow completion

Once you’ve configured all the steps, your completed flow will look as follows.

Successful pattern redaction flow

The flow will execute each action in sequence, processing your PDF through pattern redaction and saving the result to your specified location.

Viewing the redacted output

After the flow completes successfully, you can view the redacted PDF in your SharePoint document library. The sensitive information will be permanently removed from the document.

Pattern redaction output

The redacted areas appear as black boxes, ensuring sensitive information such as credit card numbers, SSNs, email addresses, and other PII is completely obscured and cannot be recovered.