pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claudius Teodorescu <claudius.teodore...@gmail.com>
Subject Rendering of a Devanagari text
Date Sat, 14 Jan 2017 07:44:17 GMT
Hi,

I am using pdfbox 2.0.4, and I am trying to output a pdf document with text
following devanagari text: कारणत्त्वङ्गवाश्वादीनमपीति
चेत् युक्तम्.

The code is very simple:
    @Test
    public void testPdfBox() throws IOException {
        PDDocument document = new PDDocument();
        PDPage page = new PDPage();
        document.addPage(page);

        PDFont font = PDType0Font.load(document,
                new
File("/home/claudius/workspaces/repositories/backup/fonts/Sanskrit2003.ttf"));

        PDPageContentStream contentStream = new
PDPageContentStream(document, page);

        contentStream.beginText();
        contentStream.setFont(font, 12);
        contentStream.moveTextPositionByAmount(100, 700);
        contentStream.showText("कारणत्त्वङ्गवाश्वादीनमपीति
चेत् युक्तम्");
        contentStream.endText();

        // Make sure that the content stream is closed:
        contentStream.close();

        // Save the results and ensure that the document is properly closed:
        document.save("target/" + name.getMethodName() + ".pdf");
        document.close();
    }

The output pdf file (attached) is not rendering correctly the string, as it
is above. Namely, the ligatures are not displayed, as if they do not exist.
On the other hand, if I am copying the text from the pdf file, and paste it
in eclipse, it shows perfectly.

I checked the pdf output with evince, firefox, and adobe reader 9, in
ubuntu.

Any idea on how to fix this display issue?

Thanks,
Claudius

-- 
http://kuberam.ro

Mime
View raw message