-
Notifications
You must be signed in to change notification settings - Fork 0
Tools
Kévin Andres edited this page Jun 25, 2021
·
3 revisions
FontUtil will help for loading font as TrueTypeFond used by PDF-Flex
exemple of font loading from a path (font within your /ressources folder):
import com.stey.lib.pdfflex.library.utils.FontUtils
/** Example for the Yahei font */
YAHEI_CLASSIC("YAHEI_CLASSIC", "/font/msyh.ttc", "MicrosoftYaHei"),
YAHEI_BOLD("YAHEI_BOLD", "/font/msyhbd.ttc", "MicrosoftYaHei-Bold"),
YAHEI_LIGHT("YAHEI_LIGHT", "/font/msyhl.ttc", "MicrosoftYaHeiLight");
val classic = FontUtils.loadTTCFont(YAHEI_CLASSIC.fontPath, YAHEI_CLASSIC.fontName)
val bold = FontUtils.loadTTCFont(YAHEI_BOLD.fontPath, YAHEI_BOLD.fontName)
val light = FontUtils.loadTTCFont(YAHEI_LIGHT.fontPath, YAHEI_LIGHT.fontName)
If you pull your font from an online provider, you can directly use TrueTypeCollection which can be created with an InputStream.
PdfImageLoader will help for loading images from a path, an URL, or Bytes and import then into apache/pdfbox, resulting in an PDImageXObject instance.
import com.stey.lib.pdfflex.library.utils.PdfImageLoader