1

I am trying to get font with UTF-8, but no success. Currently i use:

PdfPCell cell = new PdfPCell(new Paragraph(new String("čšđćž".getBytes("UTF-8")), new Font(Font.FontFamily.TIMES_ROMAN, 14)));

I get only: šž, so it is font problem?

bostek
  • 59
  • 5
  • 1
    Yes, it's a font problem. `TIMES_ROMAN` doesn't support the characters you need. You have to use a different font as explained in the [http://developers.itextpdf.com/](official documentation). Please read the answer to the question [How to use Cyrillic characters in a PDF?](http://developers.itextpdf.com/question/how-use-cyrillic-characters-pdf) – Bruno Lowagie Mar 22 '16 at 15:52
  • In addition to @Bruno's correct analysis, the construct `new String("čšđćž".getBytes("UTF-8"))` is weird, depending on the environment it either is a NOOP or an error source. Ah, and the documentation link should have looked like this: [official documentation](http://developers.itextpdf.com/). – mkl Mar 23 '16 at 09:23
  • I solved it like this: BaseFont courier = BaseFont.createFont("assets/fonts/roboto.ttf", BaseFont.IDENTITY_H,BaseFont.EMBEDDED); Font fontNormal = new Font(courier, 12, Font.NORMAL); and used also XMLWorkerHelper for HTML – bostek Mar 25 '16 at 07:49

0 Answers0