Using iTextSharp in c#
, I'm trying to add color to some text for the selected fonts in the PDF, I looked in itext documentation but couldn't find anything (or don't know where to find it).
Alternatively, I was able to add highlights to text using the pdfstamper
.
PdfAnnotation highlight = PdfAnnotation.CreateMarkup
(
pdfStamper.Writer,
TextBlock.Rect,
null,
PdfAnnotation.MARKUP_HIGHLIGHT,
Quad
);
Is there any way to add color to text, I tried the below code to add text but don't know how to reuse the existing font from the input PDF using BaseFont.CreateFont()
contentByte.BeginText();
contentByte.SetFontAndSize(BaseFont.CreateFont(), TextBlock.FontSize);
contentByte.SetTextMatrix(Rect.Left, Rect.Bottom);
contentByte.ShowText(TextBlock.Text);
contentByte.EndText();