Annotations Property (PdfPage)
Gets or sets an annotation array representing annotations associated with the page.
Here is an example that 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();
}
}
}
}
}
Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5