Use PageAreaRedaction

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Redaction MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-redaction -- dnx GroupDocs.Redaction.Mcp --yes
Folders, licensing and more →

On this page

You can use PageAreaRedaction to redact an area of a specific page range from sensitive data in text, images, and annotations. Combine it with PageRangeFilter and PageAreaFilter on ReplacementOptions. This works for PDF and for other formats that support page filters (see Supported document formats). For embedded or standalone images, area coordinates follow the page (or visible) placement of the image.

The following example demonstrates how to apply PageAreaRedaction to the right half of the last page in a PDF document.

const redaction = require('@groupdocs/groupdocs.redaction');
const java = require('java');
const Color = java.import('java.awt.Color');
const Dimension = java.import('java.awt.Dimension');
const Point = java.import('java.awt.Point');

const redactor = new redaction.Redactor('Sample.pdf');
        try 
        {
const rx = java.util.regex.Pattern.compile('urna');
const optionsText = new redaction.ReplacementOptions('[redarea]');
            optionsText.setFilters(new redaction.RedactionFilter[] {
                new redaction.PageRangeFilter(redaction.PageSeekOrigin.End, 0, 1), // last page
                new redaction.PageAreaFilter(new Point(300, 0), new Dimension(300, 840)) // right half of the page
            });
const optionsImg = new redaction.RegionReplacementOptions(Color.RED, new Dimension(100, 100));
const result = redactor.apply(new redaction.PageAreaRedaction(rx, optionsText, optionsImg));
            if (result.getStatus() !== redaction.RedactionStatus.Failed)
            {
                redactor.save();
            }                            
        }
        finally {
  redactor.close();
}

Sample.pdf is the sample file used in this example. Click here to download it.

Binary file (PDF, 68 KB)

Download full output

On this page