开发者

Java PDFBOX text encoding

开发者 https://www.devze.com 2023-02-16 16:40 出处:网络
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 charactersdisplayed properly into the pdf file. Is th

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-开发者_如何学Go7? I try something like PdFontEncoding or Encoding but I did not get anything.

Thank you for your time.


There are two things you would need to do:

  • set the encoding, and
  • provide a font with Greek characters

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号