Add Fonts in PDF using iText

Using the iText framework we have seen how to add text/paragraphs to PDF files. Now we will see how we can add various fonts and colors to the text that is added. Lets see an example on how to Add Fonts in PDF using iText.

Important class – com.itextpdf.text.Font

For setting font color use either
a) setColor(BaseColor color)
b) setColor(int red, int green, int blue)

For setting size of the font use
a) setSize(float size)

For setting font style i.e (normal, bold, italic, oblique, underline, line-through) use
a) setStyle(String style)


In this example we take two paragraphs and add various fonts, colors and styles to them.

Add Fonts in PDF using iText