Extraer Anotaciones de PDF

Contents
[ ]

ExtractAnnotations método permite extraer anotaciones de un archivo PDF. Para extraer anotaciones, necesita crear un objeto PdfAnnotationEditor y vincular el archivo PDF utilizando el método BindPdf. Después de eso, necesita crear una enumeración de los tipos de anotaciones que desea extraer del archivo PDF.

Luego puede usar el método ExtractAnnotations para extraer las anotaciones a un ArrayList. Después de eso, puede recorrer esta lista y obtener anotaciones individuales. Y finalmente, guarde el archivo PDF actualizado utilizando el método Save del objeto PdfAnnotationEditor. El siguiente fragmento de código le muestra cómo extraer anotaciones de un archivo PDF.

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ExtractAnnotation()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdfFacades_Annotations();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "AnnotationsInput.pdf"))
    {
        using (var annotationEditor = new Aspose.Pdf.Facades.PdfAnnotationEditor())
        {
            // Bind PDF document
            annotationEditor.BindPdf(document);
            // Extract annotations
            var annotationTypes = new[] { Aspose.Pdf.Annotations.AnnotationType.FreeText, Aspose.Pdf.Annotations.AnnotationType.Text };
            var annotations = annotationEditor.ExtractAnnotations(1, 2, annotationTypes);
            foreach (var annotation in annotations)
            {
                Console.WriteLine(annotation.Contents);
            }
        }
    }
}