Filtering annotations by type on saving document
Leave feedback
On this page
To save only annotations of specific types, follow these steps:
- Instantiate the Annotator class. Specify the input document path or stream.
- Instantiate the SaveOptions class. Set the AnnotationType property by specifying annotation type(s) to save.
- 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 pages with specific annotation type:
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 = 1
};
annotator.Add(new List
//Result file will contains only ellipse annotations.
annotator.Save("result.pdf" new SaveOptions { AnnotationTypes = AnnotationType.Ellipse});
}
If you need to save annotations of several types, use the OR operator ("|").
The following code snippet shows how to save pages with specific annotation types:
using (Annotator annotator = new Annotator("input.pdf"))
{
...
annotator.Save("result.pdf" new SaveOptions { AnnotationTypes = AnnotationType.Ellipse|AnnotationType.Watermark});
}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.