原創|使用教程|編輯:郝浩|2013-03-21 13:41:14.000|閱讀 1304 次
概述:注釋都包含在一個特定的頁面集合中,每個頁面都有自己的注釋集合。當添加FreeTextAnnotation在PDF文檔中時,我們為之設定格式。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
注釋都包含在一個特定的頁面集合中,每個頁面都有自己的注釋集合。當添加FreeTextAnnotation在PDF文檔中時,我們為之設定格式。使用DefaultAppearance設置字體、大小、顏色等或使用TextStyle屬性指定格式信息。此外,我們還可以更新已經存在于現有的PDF文檔的FreeTextAnnotation的格式。
[TextStyle] 允許設置字體樣式、顏色和大小。
FontName (設置字體樣式)
FontSize (獲取或者設置默認字體大小)
System.Drawing.Color Color (獲取或者設置字體顏色)
TextAligment Alignment (獲取或設置注釋中的文字對齊方式)
下面是添加指定格式的FreeTextAnnotation代碼片段
C#
//open document Document pdfDocument = new Document("c:/pdftest/TestReport.pdf"); // instantiate DefaultAppearance object Aspose.Pdf.InteractiveFeatures.DefaultAppearance default_appearance = new DefaultAppearance("Arial", 28, System.Drawing.Color.Red); //create annotation FreeTextAnnotation freetext = new FreeTextAnnotation(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(200, 400, 400, 600), default_appearance); // specify the contents of annotation freetext.Contents = "Free Text"; // add anootation to annotations collection of page pdfDocument.Pages[1].Annotations.Add(freetext); // save the updated document pdfDocument.Save("c:/pdftest/Watermarked_output_FreeText.pdf"); VB.NET
'open document Dim pdfDocument As Document = New Document("c:/pdftest/TestReport.pdf") ' instantiate DefaultAppearance object Dim default_appearance As Aspose.Pdf.InteractiveFeatures.DefaultAppearance = New InteractiveFeatures.DefaultAppearance("Arial", 28, System.Drawing.Color.Red) 'create annotation Dim freetext As FreeTextAnnotation = New FreeTextAnnotation(pdfDocument.Pages(1), New Aspose.Pdf.Rectangle(200, 400, 400, 600), default_appearance) ' specify the contents of annotation freetext.Contents = "Free Text" ' add anootation to annotations collection of page pdfDocument.Pages(1).Annotations.Add(freetext) ' save the updated document pdfDocument.Save("c:/pdftest/Watermarked_output_FreeText.pdf")
下面是更新已有FreeTextAnnotation格式的代碼片段
C#
Document doc1 = new Document("34471-2.pdf"); //set font size and color of the annotation: (doc1.Pages[1].Annotations[1] as FreeTextAnnotation).TextStyle.FontSize = 18; (doc1.Pages[1].Annotations[1] as FreeTextAnnotation).TextStyle.Color = System.Drawing.Color.Green;
VB.NET
Dim doc1 As Document = New Document("34471-2.pdf") 'set font size and color of the annotation: CType(doc1.Pages(1).Annotations(1), FreeTextAnnotation).TextStyle.FontSize = 18 CType(doc1.Pages(1).Annotations(1), FreeTextAnnotation).TextStyle.Color = System.Drawing.Color.Green
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網