如何更改FreeTextAnnotations(itext 7)的字体颜色和字体大小?

问题描述 投票:0回答:1

我创建了一个PdfFreeTextAnnotation,但setColor-Method仅是注释的背景。

如何设置实际的fontcolorfontsize和字体?

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)
pdf annotations itext itext7
1个回答
0
投票

FreeText批注具有RC键,该键允许设置富文本字符串,该字符串应用于生成批注的外观。基本上,您可以将纯HTML用作富文本字符串,例如您可以在<span>中包装一些文本,并在该跨度的style属性中设置文本颜色,就像在HTML中一样。

这是实现窍门的C#代码:

anno.SetRichText(new PdfString("<span style=\"color:#10FF10;\">Hello world</span>"));
© www.soinside.com 2019 - 2024. All rights reserved.