Class PDFFont


  • public class PDFFont
    extends java.lang.Object
    A class to handle font for PDF generation.

    It provides default font mapping for standard 14 fonts and additional fonts, and load custom fonts from a configuration json format file.

    Author:
    Jamson Chan
    • Constructor Summary

      Constructors 
      Constructor Description
      PDFFont​(org.apache.pdfbox.pdmodel.PDDocument document)
      Create a new PDFFont for the specified PDDocument.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.pdfbox.pdmodel.font.PDFont getFont​(java.lang.String fontName, char c, boolean bold, boolean italic)
      Returns the PDFont of the specified font name, character, bold and italic state, if the font name is not found or the character is not supported, it will keep searching the supported font in all fonts, if still not found, it will return the default font.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PDFFont

        public PDFFont​(org.apache.pdfbox.pdmodel.PDDocument document)
        Create a new PDFFont for the specified PDDocument.
        Parameters:
        document - the PDDocument
    • Method Detail

      • getFont

        public org.apache.pdfbox.pdmodel.font.PDFont getFont​(java.lang.String fontName,
                                                             char c,
                                                             boolean bold,
                                                             boolean italic)
        Returns the PDFont of the specified font name, character, bold and italic state, if the font name is not found or the character is not supported, it will keep searching the supported font in all fonts, if still not found, it will return the default font.
        Parameters:
        fontName - the font name
        c - the character
        bold - whether the font is bold
        italic - whether the font is italic
        Returns:
        the PDFont of the specified font name, character, bold and italic state