I want to generate a PDF that contains Bangla text. After generating PDF, text in generated PDF is broken. I have gone through a lot of Q/A related to this problem in StackOverflow, but unfortunately, I didn't find any suitable answer. here is my code...
try (PDDocument doc = new PDDocument()) {
PDPage pdPage = new PDPage(PDRectangle.A4);
doc.addPage(pdPage);
PDPageContentStream cs = new PDPageContentStream(doc, pdPage);
InputStream fontFileStream = new FileInputStream("src/main/resources/SolaimanLipi_22-02-2012.ttf");
PDFont banglaFont = PDType0Font.load(doc, fontFileStream, false);
cs.beginText();
cs.setFont(banglaFont, FONT_SIZE);
cs.newLineAtOffset(30, 500);
cs.showText("অভিনন্দন! প্রিয় আবিদ হাসান,");
cs.endText();
cs.close();
doc.save(location);
} catch (IOException e) {
log.error("PDF Error : {}", e.getMessage(), e);
}
My expected output in generated PDF.
But What I got in generated PDF (Broken).
Can anyone please help me to sort out this problem???