I'm using PDFBox to write text to PDF.
When I write English it works perfectly fine, but when I try to write Hebrew I get gibberish.
I've tried all kind of solutions but nothing seems to work. I tried everything that was described in the following threads: First, Second, Third.
All the above solutions use iText. I need to somehow manage it with PDFBox.
I did see that the use of DictionaryEncoding could work, though I don't understand it. I tried to use it but it doesn't work for Hebrew (Wrote all Hebrew letters from 1488 to 1514).
COSDictionary cosDic = new COSDictionary();
cosDic.setString( COSName.getPDFName("alef"), "1488" ); // First Hebrew letter
.
.
.
cosDic.setString( COSName.getPDFName("tav"), "1514" ); // Last Hebrew letter
font.setEncoding( new DictionaryEncoding( cosDic ) );
Any kind of help would be appreciated.
The solution for me was switching to iText.
All the hard work regarding encoding Unicode letters and RTL support in the PDF was implemented by them.
I suppose that if something is too difficult with one library there is probably another library that can do it better.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With