Class PdfFont

java.lang.Object
io.keikai.doc.io.schema.pdf.font.PdfFont

public class PdfFont extends 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

    Modifier and Type
    Method
    Description
    org.apache.pdfbox.pdmodel.font.PDFont
    getFont(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 Details

    • PdfFont

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

    • getFont

      public org.apache.pdfbox.pdmodel.font.PDFont getFont(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