Displaying embedded fonts with PDFBox and Swing

限于喜欢 提交于 2019-12-08 05:28:15

问题


I am using PDFBox to display PDF files inside a JInternalFrame. When opening PDF I get lots of warnings like this:

Changing font on <m> from <Tahoma Negrita> to the default font

I am aware that the fonts being reported are not part of the standard set of 14 fonts. So I decided to check if those fonts are embedded on the PDF file (thinking that there shouldn't be a problem loading embedded fonts, right?).

So I open the file on different readers and check properties/fonts. I am in doubt whether this section reports fonts required by the document or fonts actually embedded in the document.

The information that I get is as follows:

BAAAA+Tahoma-Bold (embedded Subset), type:TrueType, Encoding:
CAAAA+Tahoma (Embedded Subset), type:TrueType, Encoding:

Confused about this, I researched on how to embed fonts from OpenOffice and found that the PDF/A-1a option should be checked. So I made another PDF using this option (in case this was not used when making the original PDF file), yet I got the same results.

I would like your guidance understanding how this works. I would like to be able to open PDF files just as PDF readers do. I also read about the PDFBox_External_Fonts.properties but I am guessing this file shouldn't be modified since I am dealing with embedded fonts.

Thanks.


回答1:


pdfbox is not able to parse embedded subsets of TrueType fonts.

As far as I understand it, embedded TrueType subsets are missing some metadata for the font file that pdfbox needs.

The bug is known but not easy to solve. Right now I can only advise to use embedded Type 1 Fonts if possible, pdfbox can deal with them.

You can also try to set the path to your complete font files in your pdfbox.jar under org/apache/pdfbox/resources/PDFBox_External_Fonts.properties, so if pdfbox cannot parse the subset, at least it can find a full path to the original font file. Maybe that works, but I have not tested this.

Good Luck!



来源:https://stackoverflow.com/questions/12078014/displaying-embedded-fonts-with-pdfbox-and-swing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!