HTML to PDF / DOCX / RTF Java converter library Forums PD4ML Forums Technical questions / Troubleshooting Loading TTF Fonts from http URL or class path URL

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #35579

    The documentation of

    PD4ML.useTTF(pathToFontDirs, generateFontMappingFileIfMissing)

    defines, that pathToFontDirs is a “URI of TTF file directory”.
    Currently it seems, that it must be a directory in a (local) file system. Is this correct?

    Our service using PD4ML is running in a cloud environment, where the only available file system is the TEMP file system. Therefore we are copying the TTF fonts from the JAVA resources class path or from an external HTTP server to the TEMP file system on startup and setup useTTF() with this directory within TEMP. But maybe we have overlooked something.

    #35581

    The API call PD4ML.useTTF(pathToFontDirs, generateFontMappingFileIfMissing) is rather a quick hack for a missing font mapping info and it is not recommended for a prod use.

    It’s much better to generate the pd4fonts.properties mapping once and include it in your project.

    There are various methods how to configure/include fonts. See https://pd4ml.com/pdf-fonts/.

    If you’ve got a limited access to the file system, it is good idea to collect fonts to a fonts/ dir, generate pd4fonts.properties for it and to pack the fonts incl. the .properties to a JAR. Once the JAR file is deployed in your application, the fonts can be referenced using pd4ml.useTTF("java:fonts"); where “fonts” corresponds to the name of the fonts folder in the JAR file.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.