使用PDFBox和Swing显示嵌入字体 [英] Displaying embedded fonts with PDFBox and Swing

查看:425
本文介绍了使用PDFBox和Swing显示嵌入字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PDFBox在JInternalFrame中显示PDF文件。打开PDF时,我收到很多警告:

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

我知道报告的字体不是标准14的一部分字体。所以我决定检查这些字体是否嵌入在PDF文件中(认为加载嵌入字体应该没有问题,对吗?)。

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.

我得到的信息如下:

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

对此感到困惑,我研究了如何从OpenOffice嵌入字体,并发现应该检查PDF / A-1a选项。所以我使用这个选项制作了另一个PDF(如果在制作原始PDF文件时没有使用它),但我得到了相同的结果。

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.

我想要你的指导了解这是如何工作的。我希望能够像PDF阅读器一样打开PDF文件。我还读到了PDFBox_External_Fonts.properties,但我猜这个文件不应该被修改,因为我正在处理嵌入字体。

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.

谢谢。

推荐答案

pdfbox无法解析TrueType字体的嵌入子集。

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

就我而言了解它,嵌入的TrueType子集缺少pdfbox所需的字体文件的一些元数据。

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

该错误已知但不易解决。现在我只建议尽可能使用嵌入式Type 1字体,pdfbox可以处理它们。

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.

您也可以尝试设置完整字体文件的路径你的pdfbox.jar在org / apache / pdfbox / resources / PDFBox_External_Fonts.properties下,所以如果pdfbox无法解析子集,至少它可以找到原始字体文件的完整路径。也许这样可行,但我没有测试过。

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.

祝你好运!

这篇关于使用PDFBox和Swing显示嵌入字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆