Search code examples
itext7

iText missing front Arial Narrow


In iText.IO.Font.StandardFonts I don't have Arial Narrow as an options but I do have it in my C:\Windows\Fonts folder is that something I can add? Like something like this .SetFontAndSize(PdfFontFactory.CreateFont(Arial Narrow), 6.25)


Solution

  • iText.IO.Font.StandardFonts contains type 1 fonts which are typically 14. These are four Helvetica fonts (normal, bold, oblique, and bold-oblique), four Times-Roman fonts (normal, bold, italic, and bold-italic), four Courier fonts (normal,bold, oblique, and bold-oblique), Symbol and Zapfdingbats. These fonts are often referred to as the Standard Type 1 fonts. iText supports the Standard Type 1 fonts.

    If you want to use the Arial font then typically you can pass the path of .ttf file to PdfFontFactory.CreateFont("path of the arial font file"). If you intend to embed and specify encoding within it then you have an overloaded version of the same method that takes boolean as an argument. It would be something like PdfFontFactory.createFont(FONT, PdfEncodings.CP1250, true)