我创建了一个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用作富文本字符串,例如您可以在<span>
中包装一些文本,并在该跨度的style
属性中设置文本颜色,就像在HTML中一样。
这是实现窍门的C#代码:
anno.SetRichText(new PdfString("<span style=\"color:#10FF10;\">Hello world</span>"));