Reputation: 3
i create a PdfFreeTextAnnotation
but the setColor-Method
is only für the background of the Annotation.
How to set the actual fontcolor
, fontsize
and font?
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)
Upvotes: 0
Views: 730
Reputation: 12312
FreeText annotations have RC
key that allows setting a rich text string that shall be used to generate the appearance of the annotation. Basically you can use plain HTML as a rich text string, e.g. you can wrap some text in a <span>
and set the text color in style
attribute of that span, just as in HTML.
Here is the code in C# that does the trick:
anno.SetRichText(new PdfString("<span style=\"color:#10FF10;\">Hello world</span>"));
Upvotes: 1