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.

        final Redactor redactor = new Redactor("Sample.pdf");
        try 
        {
            java.util.regex.Pattern rx = java.util.regex.Pattern.compile("urna");
            ReplacementOptions optionsText = new ReplacementOptions("[redarea]");
            optionsText.setFilters(new RedactionFilter[] {
                new PageRangeFilter(PageSeekOrigin.End, 0, 1), // last page
                new PageAreaFilter(new java.awt.Point(300, 0), new java.awt.Dimension(300, 840)) // right half of the page
            });
            RegionReplacementOptions optionsImg = new RegionReplacementOptions(java.awt.Color.RED, new java.awt.Dimension(100, 100));
            redactor.apply(new PageAreaRedaction(rx, optionsText, optionsImg));
            SaveOptions saveOptions = new SaveOptions();
            saveOptions.setAddSuffix(true);
            saveOptions.setRasterizeToPDF(false);
            saveOptions.setRedactedFileSuffix("redacted");
            redactor.save(saveOptions);
        }
        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