文檔首頁(yè)>>Aspose.PDF使用教程>>Aspose.Pdf使用教程:獲取PDF文檔中的所有注釋
Aspose.Pdf使用教程:獲取PDF文檔中的所有注釋
為了從PDF文檔中獲取PDF文件頁(yè)的注釋,一般需要依次查看指定PDF頁(yè)中的Annotations注釋集。請(qǐng)注意,如果你想獲得整個(gè)PDF的所有注釋,就不得不在瀏覽注釋集合之前查看文檔的Pages頁(yè)面集合。你可以以名叫MarkupAnnotation的基礎(chǔ)注釋類型的方式得到每個(gè)集合的所有注釋,并顯示其屬性。
》》》下載Aspose.Pdf試用版
下面是代碼示例:
C#
//open document Document pdfDocument = new Document("input.pdf"); //loop through all the annotations foreach (MarkupAnnotation annotation in pdfDocument.Pages[1].Annotations) { //get annotation properties Console.WriteLine("Title : {0} ", annotation.Title); Console.WriteLine("Subject : {0} ", annotation.Subject); Console.WriteLine("Contents : {0} ", annotation.Contents); Console.WriteLine("ReadOnly : {0} ", annotation.ReadOnly); }
VB.NET
'open document Dim pdfDocument As New Document("input.pdf") 'loop through all the annotations For Each annotation As MarkupAnnotation In pdfDocument.Pages(1).Annotations 'get annotation properties Console.WriteLine("Title : {0} ", annotation.Title) Console.WriteLine("Subject : {0} ", annotation.Subject) Console.WriteLine("Contents : {0} ", annotation.Contents) Console.WriteLine("ReadOnly : {0} ", annotation.ReadOnly) Next annotation