我创建了一个PdfFreeTextAnnotation
但setColor-Method
仅用于注释的背景。
如何设置实际的fontcolor
,fontsize
和字体?
Dim rec As iText.Kernel.Geom.Rectangle = ...
Dim anno As Annot.PdfFreeTextAnnotation = New
Annot.PdfFreeTextAnnotation(rec, New PdfString(_annotation.Text))
anno.SetName(New PdfString(_annotation.Name))
anno.SetFlags(192)
anno.SetBorder(New iText.Kernel.Pdf.PdfAnnotationBorder(0, 0, 0))
pdfDoc.GetPage(_annotation.PageNumber).AddAnnotation(anno)
FreeText 注释具有RC
允许设置富文本字符串的键,该字符串将用于生成注释的外观。基本上,您可以将纯 HTML 用作富文本字符串,例如,您可以将一些文本包裹在 a 中<span>
并在style
该跨度的属性中设置文本颜色,就像在 HTML 中一样。
这是 C# 中的代码,可以解决这个问题:
anno.SetRichText(new PdfString("<span style=\"color:#10FF10;\">Hello world</span>"));
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句