1

I convert Jpanel to PDF using iText PDF, but certain special (Turkish) characters are not being displayed in the resulting PDF document.

My code is shown below:

Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(path));

document.open();
document.newPage();
Rectangle  rec = new Rectangle(0,0,panel.getWidth(), panel.getHeight());
document.setPageSize(rec);

PdfContentByte contentByte = writer.getDirectContent();
PdfGraphics2D g2 = new PdfGraphics2D(contentByte,panel.getWidth(),panel.getHeight());

panel.print(g2);
g2.dispose();
Sabuncu
  • 5,095
  • 5
  • 55
  • 89
Metin Bulak
  • 537
  • 4
  • 8
  • 30
  • What characters are not shown? – Sabuncu May 21 '20 at 16:16
  • the characters İ ş ı I Ş are not shown – Metin Bulak May 21 '20 at 17:45
  • Are those characters displayed as something else, or are they not shown at all? – Sabuncu May 21 '20 at 20:04
  • They are not shown – Metin Bulak May 21 '20 at 20:40
  • Do you have access to the book *iText in Action 2e [2011]*? That book has examples for handling non-English text (Japanese) starting on page 485. There, it says you need to use the *BaseFontParameters* class. Maybe you can apply the same principles but use Turkish fonts. Here's a link to that book: https://b-ok.org/book/922465/013206 I am not a Java person myself. – Sabuncu May 22 '20 at 11:00

0 Answers0