原創|使用教程|編輯:郝浩|2013-03-11 13:06:51.000|閱讀 1664 次
概述:要在一個PDF頁中使用Aspose.Pdf添加注釋,必須要使用Add方法將這個需要添加的注釋添加到Annotations注釋集中。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
這個地方的所說的注釋包含在每個特定頁的注釋集中。因為每個PDF頁都有自己單獨的注釋集,所以這個注釋集也只是收錄這個PDF頁中的注釋。要在一個PDF頁中使用Aspose.Pdf添加注釋,必須要使用Add方法將這個需要添加的注釋添加到Annotations注釋集中。所以第一步是創建一個新的注釋,然后打開PDF文件,將之添加到該頁的注釋集中。
》》》下載Aspose.Pdf試用版
下面是具體的代碼示例:
C#
//open document
Document pdfDocument = new Document("input.pdf");
//create annotation
TextAnnotation textAnnotation = new TextAnnotation(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(200, 400, 400, 600));
textAnnotation.Title = "Sample Annotation Title";
textAnnotation.Subject = "Sample Subject";
textAnnotation.State = AnnotationState.Accepted;
textAnnotation.Contents = "Sample contents for the annotation";
textAnnotation.Open = true;
textAnnotation.Icon = TextIcon.Key;
Border border = new Border(textAnnotation);
border.Width = 5;
border.Dash = new Dash(1, 1);
textAnnotation.Border = border;
textAnnotation.Rect = new Aspose.Pdf.Rectangle(200, 400, 400, 600);
//add annotation in the annotations collection of the page
pdfDocument.Pages[1].Annotations.Add(textAnnotation);
////save output file
pdfDocument.Save("output.pdf");
VB.NET
'open document
Dim pdfDocument As New Document("input.pdf")
'create annotation
Dim textAnnotation As New TextAnnotation(pdfDocument.Pages(1), New Aspose.Pdf.Rectangle(200, 400, 400, 600))
textAnnotation.Title = "Sample Annotation Title"
textAnnotation.Subject = "Sample Subject"
textAnnotation.State = AnnotationState.Accepted
textAnnotation.Contents = "Sample contents for the annotation"
textAnnotation.Open = True
textAnnotation.Icon = TextIcon.Key
Dim border As New Border(textAnnotation)
border.Width = 5
border.Dash = New Dash(1, 1)
textAnnotation.Border = border
textAnnotation.Rect = New Aspose.Pdf.Rectangle(200, 400, 400, 600)
'add annotation in the annotations collection of the page
pdfDocument.Pages(1).Annotations.Add(textAnnotation)
'//save output file
pdfDocument.Save("output.pdf")
					本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@ke049m.cn
文章轉載自:慧都控件網