Extract Annotations from PDF

[ ]

ExtractAnnotations method allows you to extract annotations from a PDF file. In order to extract annotations, you need to create PdfAnnotationEditor object and bind PDF file using BindPdf method. After that, you need to create an enumeration of annotation types which you want to extract from PDF file.

You can then use ExtractAnnotations method to extract the annotations to an ArrayList. After that, you can loop through this list and get individual annotations. And finally, save the updated PDF file using Save method of the PdfAnnotationEditor object. The following code snippet shows you how to extract annotations from PDF file.

 public static void ExtractAnnotation()
            var document = new Document(_dataDir + "sample_cats_dogs.pdf");
            PdfAnnotationEditor annotationEditor = new PdfAnnotationEditor();

            // Extract annotations
            var annotationTypes = new[] { AnnotationType.FreeText, AnnotationType.Text };
            var annotations = annotationEditor.ExtractAnnotations(1, 2, annotationTypes);
            foreach (var annotation in annotations)