0

I am trying to generate a PDF using itextpdf 5.5.11 and xmlworker 5.4.2 jars respectively. When I run my java code locally on a WINDOWS machine, the Russian characters are getting displayed fine in the PDF generated. However, when the same Java code runs on a LINUX server, the russian characters are not getting displayed in the PDF generated.

I have tried installing fonts on the linux server under path /usrs/share/fonts. However, the issue still exists. Sharing the snippet of the code where Charset is also included while parsing the input html.

pdfdoc.open();
XMLWorkerHelper worker = XMLWorkerHelper.getInstance();
worker.parseXHtml(pdfWriter, pdfdoc, new ByteArrayInputStream(html), new ByteArrayInputStream(css),Charset.forName("UTF-8"));
pdfdoc.close();

The PDF should be generated with Russian characters irrespective of the server on which this java code is executed.

Uladzimir Asipchuk
  • 2,368
  • 1
  • 9
  • 19
Sheetal
  • 1
  • 2
  • 1
    You are mixing incompatible versions of itextpdf and xmlworker. Make sure that they are both the same version! 5.5.13 is the latest version of iText 5. – Amedee Van Gasse May 15 '19 at 08:04
  • 1
    (*) with incompatible, I mean: not guaranteed by iText Software to be compatible. – Amedee Van Gasse May 15 '19 at 08:05
  • @AmedeeVanGasse this is working fine when tested locally with these version of jars in eclipse. – Sheetal May 15 '19 at 08:36
  • I am QA Engineer @ iText Software, and I am telling you that is only by lucky coincidence that it works ok for you. Your code might just not be hitting any of the API that is incompatible. Versions `5.4.2` and `5.5.11` are **not** guaranteed to be compatible and if you get any errors or other unexpected behavior, then you are **strongly recommended** to have them both at the same version. You write _"with these version of jars in eclipse"_, that also tells me that you are probably not using any dependency management like Maven or Gradle, is that correct? – Amedee Van Gasse May 15 '19 at 15:37
  • Hi Sheetal, you have also sent your question to iText Software directly, and one of our support engineers is already working on it. There's a request for more details, you should get that soon if you haven't got it already. – Amedee Van Gasse May 16 '19 at 14:52
  • You write that you are using the path `/usrs/share/fonts` on Linux. Could you please double check that for typos? `/usrs` typically does not exist on Linux, but `/usr` does. – Amedee Van Gasse May 17 '19 at 07:22
  • Hi, I was able to show Russian characters following this: https://kb.itextpdf.com/home/it5kb/faq/how-to-make-cyrillic-characters-display-properly-when-converting-html-to-pdf – RASMiranda Mar 11 '21 at 08:57

0 Answers0