When rendering a PDF document in the following Qoppa’s PDF library products: jPDFImages, jPDFPrint, jPDFProcess, jPDFViewer, jPDFNotes or jPDFEditor, you might encounter a blank page with an “Error Rendering Page” displayed in red on a page. This error happens when there is an issue with a font within the PDF document. There are 2 possible font errors:
Missing Font
This happens because the PDF document is calling for a font, ‘F0’ in this case, that is not embedded in the document and can not be found on the computer by name.
According to the PDF specifications, such a PDF is a malformed document and the creator of the document should correct this document by embedding the font.
If you have enabled debugging, the following error log will show in your log (where ‘F0’ is the actual name of the missing font):
com.qoppa.pdf.PDFException: Missing Font: F0
Error Loading Embedded Font
A similar rendering issue happens when a font that is supposed to be embedded can not be loaded:
How Can I resolve this Issue?
It is possible to enable font substitution to workaround by making the following static call:
// You only need to make this static call once FontSettings.setUseSubstituteFont(true); // You can now make calls to the library // to open PDFs, etc... |
If you are running an older version (v2016R1 and lower) of Qoppa libraries, the call is the following:
// You only need to make this static call once PDFErrorHandling.setUseSubstituteFont(true); // You can now make calls to the library // to open PDFs, etc... |
This call is static so only need to be made once, before rendering or converting a PDF page.
What Font is Used for Substitution?
If you enable font substitution (as mentioned above), we will use the following fonts for rendering:
- For non-embedded fonts, we fall back to either Java Serif or Java Sans Serif (when no standard font or system font can be found by name).
- For embedded fonts that we fail to load, we currently fall back to the standard Helvetica® font. We’re planning to change this behavior soon to mirror the behavior for non-embedded fonts.
Note: Helvetica® is a trademark Monotype Imaging Inc.