Reputation: 449
I'm generating a pdf using the Apache PDFBox library in Java. I've embedded a font in the pdf, but whenever I open the pdf I get an error that says:
"The font font_name contains bad /Widths"
This error occurs no matter what the font is that is embedded, but the font and the pdf are still displayed correctly after you hit "OK" on that error. However, for production code it is unacceptable to have this warning pop up on every pdf that is generated even if the pdf is correctly rendered.
Is there a workaround for this so that I can avoid the error popping up?
For reference here is the related bug (this is in version 1.4, which I would like to continue using rather than going back to 1.3)
And here is the code used to embed the font:
font = PDTrueTypeFont.loadTTF( doc, new File( "VERDANA.ttf" ));
Upvotes: 0
Views: 7288
Reputation: 95928
This issue has been resolved in July 2012 and the first version containing the fix is 1.7.1.
For details cf. the issue PDFBOX-954 in the Apache Jira.
Upvotes: 0
Reputation: 69
only using PDType1Font.FONT works fine until you have a need for 'embedding true type fonts' into pdf document (which many publishers require), which is done by loading it from ttf file as OP did.
whilst embedding becomes necessary probable workaround could be,
font = PDTrueTypeFont.loadTTF( doc, new File( "helveltica.ttf" ));
font.setWidths(PDType1Font.HELVETICA.getWidths());
looking fwd to a permanent fix to this issues in next ver of pdfbox! :)
Upvotes: 0