Java PDFBOX 文本编码
我尝试将 Java 应用程序中的一些数据导出到 pdf 文件。我决定使用 pdfBox 库,但我意识到我无法将希腊字符正确显示到 pdf 文件中。有没有办法设置编码?到 utf8,还是 iso-8859-7?我尝试了 PdFontEncoding 或 Encoding 之类的东西,但我没有得到任何结果。
感谢您抽出时间。
I try to export some data from my Java application to a pdf file. I decided to use the pdfBox library,but I realized that I could not do the Greek characters displayed properly into the pdf file. Is there a way to set the encoding? to utf8, or iso-8859-7? I try something like PdFontEncoding or Encoding but I did not get anything.
Thank you for your time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要做两件事:
大多数 PDF 阅读器(即 Adobe Reader、OS X Preview 等)拥有的内置字体仅具有latin1 编码,不包含希腊字符。请参阅 http://libharu.sourceforge.net/fonts.html
我的猜测是这个问题不是编码的问题,而是字体的问题。您需要获取带有希腊字符的字体并将其嵌入到 PDF 文件中。确保您拥有嵌入字体的许可证!
另请参阅使用 Java PDFBox 库编写俄语 PDF
There are two things you would need to do:
The inbuilt fonts that most PDF readers have (ie Adobe Reader, OS X Preview, etc) only have the latin1 encoding, which doesn't include Greek characters. See http://libharu.sourceforge.net/fonts.html
My guess is that problem here is not with the encoding, instead the problem is the font. You will need to obtain a font with Greek characters and embed it in the PDF file. Make sure you have a licence to embed the font!
See also Using Java PDFBox library to write Russian PDF