• <menu id="w2i4a"></menu>
  • logo Aspose.PDF使用教程

    文檔首頁(yè)>>Aspose.PDF使用教程>>Aspose.Pdf使用教程:為FreeTextAnnotation設(shè)置格式

    Aspose.Pdf使用教程:為FreeTextAnnotation設(shè)置格式


    注釋都包含在一個(gè)特定的頁(yè)面集合中,每個(gè)頁(yè)面都有自己的注釋集合。當(dāng)添加FreeTextAnnotation在PDF文檔中時(shí),我們?yōu)橹O(shè)定格式。使用DefaultAppearance設(shè)置字體、大小、顏色等或使用TextStyle屬性指定格式信息。此外,我們還可以更新已經(jīng)存在于現(xiàn)有的PDF文檔的FreeTextAnnotation的格式。

    》》》下載Aspose.Pdf試用版

    [TextStyle] 允許設(shè)置字體樣式、顏色和大小。

    FontName (設(shè)置字體樣式)

    FontSize (獲取或者設(shè)置默認(rèn)字體大小)

    System.Drawing.Color Color (獲取或者設(shè)置字體顏色)

    TextAligment Alignment (獲取或設(shè)置注釋中的文字對(duì)齊方式)

    下面是添加指定格式的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
    
    掃碼咨詢(xún)


    添加微信 立即咨詢(xún)

    電話(huà)咨詢(xún)

    客服熱線(xiàn)
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();