PDF not rendered with custom font

In our print settings, we have uploaded aria.ttf and use it in our print models. The preview app does render the PDF correctly by using the font.

Unfortunately, this does not work in our deployed application. Arial is not used and the fallback is used (I think Open Sans here.)

I have taken a quick look into the a12 print project to see where the uploaded font from the “fontAttachment” field is loaded and found the sources in the “print-workspace” module.
Do I have to configure anything so that this loading takes place? Let me know what additional information you need here.
We started with the basic project template in case this matters.

Hi @matthias-modular-brook,

I guess your deployed application needs explicit font configuration in the Print Engine setup itself.

So configure the custom fonts when you initialize your Print Engine. You need to add the font configuration to either PrintEngineConfig (if you’re still using the old engine) or PdfBoxPrintEngineConfig (which is recommended since the old engine will be removed in 2026.06).

For the new PdfBoxPrintEngine, it would look something like this:

PdfBoxPrintEngineConfig config = PdfBoxPrintEngineConfig.builder()
    .availableFonts(Map.of(
        "Arial", "classpath:/fonts/arial.ttf"  // or use "file:/absolute/path/to/arial.ttf"
    ))
    .build();

PdfBoxPrintEngine pdfBoxPrintEngine = new PdfBoxPrintEngine(pool, config);

The key point in here is that the map key (“Arial”) needs to match exactly what’s referenced in your Print Model. Also make sure to place your arial.ttf file in src/main/resources/fonts/ if you’re using the classpath approach, or provide an absolute file path with the file:/ prefix.

This configuration happens during Print Engine initialization as part of your configuration setup. Since you started with the basic project template, you’ll want to add this to wherever you’re creating your Print Engine instance.

Further readings:

Thank you for your help!

Note that the deprecated PrintEngineConfigBuilder starts with a clean config and does not use any defaults (and has no withDefaults() method). This might result in NullPointerExceptions during runtime.
The following code worked for me:

Map<String,String> fonts = new HashMap<>(PrintEngineConfig.DEFAULT_FONTS);
fonts.putAll(Map.of("Arial", "classpath:fonts/arial.ttf"));
PrintEngineConfig config = PrintEngineConfig.DEFAULT;
config.setAvailableFonts(fonts);
pdfPrintEngine = new PdfPrintEngine(engineExecutorService, config);