Use PDF redaction filters

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 combine PageRangeFilter and PageAreaFilter in one set to limit a redaction to an area on a specific page (or slide). Assign the filters array to the Filters property of ReplacementOptions. The same approach applies to PDF and to other formats that support page filters.

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

        final Redactor redactor = new Redactor("Sample.pdf");
        try 
        {
            // Get the actual size information for the last page:
            IDocumentInfo info = redactor.getDocumentInfo();
            PageInfo lastPage = info.getPages().get(info.getPageCount() - 1);
            ReplacementOptions options = new ReplacementOptions("[secret]");
            options.setFilters(new RedactionFilter[] {
                new PageRangeFilter(PageSeekOrigin.End, 0, 1),
                new PageAreaFilter(new java.awt.Point(0, lastPage.getHeight()/2),
                    new java.awt.Dimension(lastPage.getWidth(), lastPage.getHeight()/2))
            });
            RedactorChangeLog result = redactor.apply(new ExactPhraseRedaction("bibliography", false, options));
            if (result.getStatus() != RedactionStatus.Failed)
            {
                redactor.save();
            }                            
        }
        finally { redactor.close(); }

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

Binary file (PDF, 1018 KB)

Download full output

On this page