VintaSoft Imaging .NET SDK v8.6
Vintasoft.Imaging.Pdf.Tree Namespace / PdfPage Class / Annotations Property
Example



In This Topic
    Annotations Property (PdfPage)
    In This Topic
    Gets or sets an annotation array representing annotations associated with the page.
    Syntax
    'Declaration
     
    <BrowsableAttribute(False)>
    Public Property Annotations As PdfAnnotationList
    [Browsable(false)]
    public PdfAnnotationList Annotations {get; set;}
    [Browsable(false)]
    public: __property PdfAnnotationList* get_Annotations();
    public: __property void set_Annotations( 
       PdfAnnotationList* value
    );
    [Browsable(false)]
    public:
    property PdfAnnotationList^ Annotations {
       PdfAnnotationList^ get();
       void set (    PdfAnnotationList^ value);
    }
    Example
    This example shows how to obtain an information about all annotations of PDF page.
    ''' <summary>
    ''' Gets and prints information about all annotations of PDF page.
    ''' </summary>
    ''' <param name="pdfFileName">The filename of PDF document.</param>
    Public Shared Sub PrintAnnotationsInfo(pdfFileName As String)
        ' open PDF document
        Using document As New Vintasoft.Imaging.Pdf.PdfDocument(pdfFileName)
            ' for each PDF page
            For pageIndex As Integer = 0 To document.Pages.Count - 1
                ' get PDF page
                Dim page As Vintasoft.Imaging.Pdf.Tree.PdfPage = document.Pages(pageIndex)
                ' get a collection of annotations of PDF page
                Dim annotations As Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationList = page.Annotations
                If annotations Is Nothing Then
                    System.Console.WriteLine("Page {0}: no annotations.", pageIndex + 1)
                Else
                    ' print the page index and count of annotations
                    System.Console.WriteLine("Page {0} Annotation count: {1}", pageIndex + 1, annotations.Count)
                    ' for each annotation
                    For Each annotation As Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotation In annotations
                        ' print information about annotation
                        System.Console.WriteLine("Annotation:")
                        System.Console.WriteLine("           Name: ""{0}""", annotation.Name)
                        System.Console.WriteLine(" Title (Author): ""{0}""", annotation.Title)
                        System.Console.WriteLine("        Subject: ""{0}""", annotation.Subject)
                        System.Console.WriteLine("       Contents: ""{0}""", annotation.Contents)
                        System.Console.WriteLine("AppearanceState: ""{0}""", annotation.AppearanceState)
                        System.Console.WriteLine("       Modified: {0}", annotation.Modified)
                        System.Console.WriteLine("          Flags: {0}", annotation.Flags)
                        System.Console.WriteLine()
                    Next
                End If
            Next
        End Using
    End Sub
    /// <summary>
    /// Gets and prints information about all annotations of PDF page.
    /// </summary>
    /// <param name="pdfFileName">The filename of PDF document.</param>
    public static void PrintAnnotationsInfo(string pdfFileName)
    {
        // open PDF document
        using (Vintasoft.Imaging.Pdf.PdfDocument document = 
            new Vintasoft.Imaging.Pdf.PdfDocument(pdfFileName))
        {
            // for each PDF page
            for (int pageIndex = 0; pageIndex < document.Pages.Count; pageIndex++)
            {
                // get PDF page
                Vintasoft.Imaging.Pdf.Tree.PdfPage page = document.Pages[pageIndex];
                // get a collection of annotations of PDF page
                Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationList annotations = page.Annotations;
                if (annotations == null)
                {
                    System.Console.WriteLine("Page {0}: no annotations.", pageIndex + 1);
                }
                else
                {
                    // print the page index and count of annotations
                    System.Console.WriteLine("Page {0} Annotation count: {1}", pageIndex + 1, annotations.Count);
                    // for each annotation
                    foreach (Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotation annotation in annotations)
                    {
                        // print information about annotation
                        System.Console.WriteLine("Annotation:");
                        System.Console.WriteLine("           Name: \"{0}\"", annotation.Name);
                        System.Console.WriteLine(" Title (Author): \"{0}\"", annotation.Title);
                        System.Console.WriteLine("        Subject: \"{0}\"", annotation.Subject);
                        System.Console.WriteLine("       Contents: \"{0}\"", annotation.Contents);
                        System.Console.WriteLine("AppearanceState: \"{0}\"", annotation.AppearanceState);
                        System.Console.WriteLine("       Modified: {0}", annotation.Modified);
                        System.Console.WriteLine("          Flags: {0}", annotation.Flags);
                        System.Console.WriteLine();
                    }
                }
            }
        }
    }
    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also