Save only annotated pages

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