Save specific page range

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.Annotation 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-annotation -- dnx GroupDocs.Annotation.Mcp --yes
Folders, licensing and more →

On this page

To export the specific page range, follow these steps:

  1. Instantiate the Annotator class. Specify the input document path or stream.
  2. Instantiate the SaveOptions class. Call the setFirstPage and  setLastPage methods to specify the first and the last pages.
  3. Call the save() method with the output document path or stream. Specify the SaveOptions class as a parameter.

The following code demonstrates how to save the range of document page:

// This example demonstrates saving result document with specified pages.

// Create an instance of Annotator class
Annotator annotator = new Annotator("inputPath");
try {
    SaveOptions tmp0 = new SaveOptions();
    tmp0.setFirstPage(2);
    tmp0.setLastPage(4);
    
    // Save to file
    annotator.save(outputPath, tmp0);
} finally {
    if (annotator != null) {
        annotator.dispose();
    }
}

On this page