Select specific pages for rasterized PDF

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 →

Select specific pages for rasterized PDF

Saving document as a rasterized PDF, you can specify starting page index (zero based) and the number of pages from this index to save. Also, you can change the Compliance level from PDF/A-1b, which is used by default, to PDF/A-1a:

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

const redactor = new redaction.Redactor('MultipageSample.docx');
try 
{
const result = redactor.apply(new redaction.ExactPhraseRedaction('John Doe', new redaction.ReplacementOptions(Color.RED)));
    if (result.getStatus() !== redaction.RedactionStatus.Failed)
    {
const options = new redaction.SaveOptions();
        options.getRasterization().setEnabled(true);                           // the same as options.RasterizeToPDF = true;
        options.getRasterization().setPageIndex(5);                            // start from 6th page (index is 0-based)
        options.getRasterization().setPageCount(1);                            // save only one page
        options.getRasterization().setCompliance(PdfComplianceLevel.PdfA1a);   // by default PdfComplianceLevel.Auto or PDF/A-1b
        options.setAddSuffix(true);
        redactor.save(options);
    }
}
finally {
  redactor.close();
}

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

Binary file (PDF, 10.7 MB)

Download full output