Extract Annotation (facades)

Contents
[ ]

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. 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();
        annotationEditor.bindPdf(document);

        // Extract annotations
        var annotationTypes = new int[] { AnnotationType.FreeText, AnnotationType.Text };
        var annotations = annotationEditor.extractAnnotations(1, 2, annotationTypes);
        for (var annotation : annotations) {
            System.out.println(annotation.getContents());
        }