2

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.

enter image description here

But What I got in generated PDF (Broken).

enter image description here

Can anyone please help me to sort out this problem???

Muhammad Saimon
  • 233
  • 2
  • 10
  • 1
    Complex scripts are not supported. There was an effort to do this but it stopped. If you're using the trunk and build it, you could try. It works with bengali if the fonts are not subsetted, I don't know if it would work with bangla. I tried it and it seems ok, but I'm obviously unqualified to recognize the glyphs. – Tilman Hausherr Feb 16 '21 at 03:56
  • Did you find any solution? – Partho63 Jan 24 '22 at 06:44
  • No, see https://issues.apache.org/jira/browse/PDFBOX-4189 – Tilman Hausherr Jan 24 '22 at 08:47

0 Answers0