fontsitextfont-style

How do I get my text to be both bold and italic in iText?


I am trying to make my text both bold and italic at the same time for a paragraph in a PDF document using iText.

I can use either of these for bold:

Font font = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.FontStyle.BOLD.ordinal());

and italic:

Font font = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.FontStyle.ITALIC.ordinal());

but not both simultaneously.

How can I use both?


Solution

  • Try

    Font font = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLDITALIC);