Mendix Document Generation marketplace module - custom fonts not rendered

0
Mendix Version: 9.24.40Document Generation Version: 1.11.4 (Mendix 9 LTS)When using the Document Generation module to generate a pdf of the following page, the custom fonts are not rendered in the file.This is for an app hosted on Mendix Public Cloud, docgen app registration completed.The page is as follows, using Impact and Ariel Narrow fonts, displayed as expected when opened within the app:But the resulting PDF renders the text in a single different font:Fonts are located within the file structure and retrieved relatively by a font-face @-rule, then used in custom classes assigned to each text widget.Does docgen have an issue with fonts served in this way? Or is there some other cause of this issue?
asked
1 answers
1

Hi Owen,


The PDF Document Generation module uses a headless Chromium browser to render the page, so custom fonts should be loaded and applied correctly in the browser before the PDF is generated.

Since the fonts display correctly in the application but not in the generated PDF, I would check the following:

  1. Verify the font URL: Make sure the .ttf, .woff, or .woff2 files are served from your application and are accessible to the Document Generation service. Avoid relying on local file paths or external font URLs that may not be accessible from the rendering environment.
  2. Check the @font-face configuration: Confirm that the font family name used in your CSS matches the name declared in @font-face, and that the correct font file and weight are configured.
  3. For example:
@font-face {
    font-family: 'ImpactCustom';
    src: url('/fonts/impact.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

.impact-custom {
    font-family: 'ImpactCustom', sans-serif;
}
  1. Adjust the URL to match the actual location of your font file.
  2. Wait for fonts to load: If the page is rendered before the custom fonts finish loading, Chromium may generate the PDF using a fallback font. Check whether the fonts are loaded successfully and applied before PDF generation.
  3. Inspect the page in Chromium: Temporarily expose the page used for PDF generation through a normal application navigation and inspect it using Chrome DevTools. Check the Network tab for failed font requests and the Computed Styles panel to confirm which font is actually being used.
  4. Check the font files and licensing: Ensure the font files are valid, support the required characters, and can legally be embedded or used in generated documents.


Mendix's official documentation also recommends placing custom font files in theme/web/fonts, declaring them using @font-face in main.scss, and applying the corresponding CSS class to the text and widgets.


Reference: PDF Document Generation — Applying Custom Fonts

If the font loads successfully in the browser but still falls back in the generated PDF, please share the @font-face declaration and the font file format. That will help narrow down whether this is a font-loading issue or a rendering-specific issue.


Hope this helps.

answered