1

I use PDFjet. In some cases I get into trouble when I generate latin alphabets from central or southern european languages such as turkish, hungarian, czech. Especially letters like ş ç ğ ı are not shown in my generated pdf text.

Any ideas how to set the right Unicode?

Ramses
  • 652
  • 2
  • 8
  • 30

1 Answers1

0

I have solved that problem with loading custom font that contains these letters. In my case it was for Android but it should be the same in Java.

I have saved the ttfs in /assets/fonts folder of my project. Then I loaded the font and used it in Font constructor.

Page page = new Page(pdf, A4.PORTRAIT);

BufferedInputStream bis = new BufferedInputStream(
            getClass().getResourceAsStream(
                    "/assets/fonts/DejaVu/ttf/DejaVuLGCSerif.ttf.deflated"));

Font f = new Font(pdf, bis);
TextLine text = new TextLine(f,"ş ç ğ ı");
text.drawOn(page);
Daniel
  • 31
  • 1
  • 4