Itext 5 do not display correctly at generated pdf file for Myanmar Unicode fonts.
Itext version : 5.5.13.1
Expectation Result : သီဟိုဠ်မှ ဉာဏ်ကြီးရှင်သည်အာယုဝဎ္ဍနဆေးညွှန်းစာကို ဇလွန်ဈေးဘေးဗာဒံပင်ထက် အဓိဋ္ဌာန်လျက် ဂဃနဏဖတ်ခဲ့သည်။
Actual Result :
Google Drive Link for generated PDF.
My test string is similar with "The quick brown fox jump over the lazy dog" in English. It contains most of Myanmar alphabets.
Java program that I used to product above pdf
String fileName = "sample.pdf";
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
Document doc = new Document();
PdfWriter writer = PdfWriter.getInstance(doc, baos);
writer.setCloseStream(false);
BaseFont unicode = BaseFont.createFont("/fonts/NotoSansMyanmar-Regular.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Font myanmarUniCodeFont = new Font(unicode, 11, Font.NORMAL, BaseColor.BLACK);
Rectangle pageSize = new Rectangle(PageSize.A4);
doc.setPageSize(pageSize);
doc.open();
String textStr = "သီဟိုဠ်မှ ဉာဏ်ကြီးရှင်သည်အာယုဝဎ္ဍနဆေးညွှန်းစာကို ဇလွန်ဈေးဘေးဗာဒံပင်ထက် အဓိဋ္ဌာန်လျက် ဂဃနဏဖတ်ခဲ့သည်။";
doc.add(new Paragraph(textStr, myanmarUniCodeFont));
doc.close();
}
catch (Exception e) {
e.printStackTrace();
}
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
response.setHeader("Cache-Control", "no-cache,no-store,max-age=0");
response.setHeader("Pragma", "No-cache");
response.setHeader("Content-Disposition", "inline; filename=" + fileName);
response.setContentType("application/pdf");
response.setContentLength(baos.size());
OutputStream os = response.getOutputStream();
baos.writeTo(os);
os.flush();
os.close();
baos.close();
Ouput texts are correct (you can copy and paste into a text editors like Notepad++ and see the result) but wrong display at pdf file.
What should I do to display correctly Myanmar Unicode Font by using itext-pdf-5 ?
Now I'm using dirty way to see the fonts readable. I converted all unicode strings to "Zawgyi Font" (This is another Myanmar font and we should never use this.) and embeded into pdf. This is not good solution and we can't promise all unicodes are correctly converted to Zawgyi-One font string and I don't want to convert unicode texts to non-standard texts. That's why I don't want to use this way.
Edited about ZawGyi Font with Itext
Some texts also do not render correctly with itext . Eg : သိန္နီ ၊ ဂွ

