Pre-rasterize

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

In some cases, you might need to pre-rasterize the document before opening it and applying redactions.

For instance, you might need to use an ImageAreaRedaction for a whole page of a document with searchable text and images. In order to do that, you will need to pass the Boolean flag to the LoadOptions class constructor.

The following example demonstrates how to pre-rasterize a Microsoft Word 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 loadOptions = new redaction.LoadOptions(/*preRasterize*/ true);
const redactor = new redaction.Redactor('sample.docx', loadOptions);
        try 
        {
            // Make changes to the file as a rasterized PDF, e.g. uisng ImageAreaRedaction:
const samplePoint = new Point(516, 311);
const sampleSize = new Dimension(170, 35);
const result = redactor.apply(new redaction.ImageAreaRedaction(samplePoint,
                new redaction.RegionReplacementOptions(Color.RED, sampleSize)));
            if (result.getStatus() !== redaction.RedactionStatus.Failed)
            {
                    redactor.save();
            };
        }
        finally {
  redactor.close();
}
}

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

Binary file (PDF, 940 KB)

Download full output

save() writes the PDF in the same folder as the source file.

On this page