0

I am using pdfbox to create a pdf file in "Gujarati" language. Some of the characters are not displayed correctly in PDF but when I copy the same from pdf to notepad, the characters are displayed correctly.

Following is the code snippet :

PDDocument document = new PDDocument();
        PDPage newPage = new PDPage();
        document.addPage(newPage);
        PDType0Font titleFont = PDType0Font.load(document, new FileInputStream("./fonts/arial-unicode-ms.ttf"), true);
        PDPageContentStream contentStream = new PDPageContentStream(document, newPage);
        contentStream.beginText();
        contentStream.setFont(titleFont, 9);
        contentStream.newLineAtOffset(30, 600);
        contentStream.showText("માહિતી");
        System.out.println("માહિતી");
        contentStream.endText();
        contentStream.close();
        document.save("newFile.pdf");
        document.close();

Pdf Screenshot :

This is how it shows up in pdf

mkl
  • 90,588
  • 15
  • 125
  • 265

0 Answers0