Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.0.32, 3.0.3 PDFBox
-
None
-
Ubuntu 22.04
Description
We've encountered some PDFs that have characters written using the ZapfDingbats symbol font. On Windows PdfBox recreates the symbols appropriately, but when testing on Ubuntu 22.04 we've noticed that many symbols, such as the heavy checkmark (U+2714) are missing. Instead an empty character is produced.
Upon debugging it appears that the PdfBox toolkit substitutes the ZapfDingbats font for some other font instead. In our observation, the code attempts to fallback to "Helvetica," but because this font is not present the last-resort "LiberationSans" is selected instead. This font is not capable of displaying the heavy checkmark symbol (a20/U+2714) and hence it is missing when the PDF page is rendered to an image. The following appears in the Debug console:
WARNING: Using fallback font LiberationSans for ZapfDingbats
While debugging, if we inject the font name "DejaVuSans" into the variable for "fallbackName" in the FontMapperImpl::getFontBoxFont(String, PDFontDescriptor) method, then DejaVuSans is instead resolved as the base font and the heavy checkmark symbol (and others) is drawn correctly.
It's not clear to us why a more appropriate font is not chosen in this instance. It results in many ZapfDingbats symbols missing when the page is rendered.
This PDF file demonstrates the problem.
Steps to Reproduce:
- Create a Java project and import PdfBox v2.0.32
- Execute the below code snippet, substituting the placeholder file paths for real ones on your system, on Ubuntu 22.04
- Observe that the image file that is produced is missing many symbols.
String inputPath = "zapf-dingbats.pdf"; File pdfFile = new File(inputPath); try (PDDocument pdfDoc = PDDocument.load(pdfFile)) { PDFRenderer renderer = new PDFRenderer(pdfDoc); BufferedImage image = renderer.renderImage(0); String outputPath = "zapf-dingbats.ubuntu.png"; try (OutputStream outFile = new FileOutputStream(outputPath)) { ImageIOUtil.writeImage(image, "PNG", outFile); } } catch (IOException e) { e.printStackTrace(); }
Attachments
Attachments
Issue Links
- is related to
-
PDFBOX-5924 Icons of text annotations sometimes too large
- Resolved