如何更改 FreeTextAnnotations (itext 7) 的字体颜色和字体大小?
How to change font color and fontsize of FreeTextAnnotations (itext 7)?
我创建了一个 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>"));
我创建了一个 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>"));