Save only annotated pages

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 to output document only annotated pages, follow these steps:

  1. Instantiate the Annotator class. Specify the input document path or stream.
  2. Instantiate the SaveOptions class. Set the OnlyAnnotatedPages property to true.
  3. Call the Save method with the output document path or stream. Specify the SaveOptions class as a parameter. The following code snippet shows how to save only annotated pages:
// for this example input file ("input.pdf") must have at least 10 pages
using (Annotator annotator = new Annotator("input.pdf"))
{
	AreaAnnotation area = new AreaAnnotation()
    {
    	Box = new Rectangle(100, 100, 100, 100),
        BackgroundColor = 65535,
        PageNumber = 1
    };
    EllipseAnnotation ellipse = new EllipseAnnotation()
    {
        Box = new Rectangle(100, 100, 100, 100),
        BackgroundColor = 123456,
        PageNumber = 9
    };
    //Result file will be contain only two pages (1 and 9)
    annotator.Add(new List<AnnotationBase>() { area, ellipse });
    annotator.Save("result.pdf" new SaveOptions { OnlyAnnotatedPages = true});
}

On this page