简体   繁体   中英

Generation of Telugu PDF from HTML using ITextRenderer does not getting exact characters?

Generation of Telugu PDF from HTML using ITextRenderer does not getting exact characters? Getting broken charecter(expected charecters వినియోగించుకోకపోయినట్లయితే ) in the pdf. attached screen shot. enter image description here

We are using below code for generating UTF-8 pdf with font

1) body * { font-family: "Vani", Georgia, Serif;}

2)Document doc = builder.parse(new ByteArrayInputStream(content.toString().getBytes("UTF-8")));

3)renderer.getFontResolver().addFont(contextPath+"fonts/VANI.TTF",BaseFont.IDENTITY_H,BaseFont.EMBEDDED); 4) jars itext 4.2 and core-render.jar

Please help to get the excepted output in the PDF.

You are using ITextRenderer which leads to believe that you are using Flying Saucer. Flying Saucer is not iText. Flying Saucer is a third party product that uses an old version of iText, and that is not endorsed by iText Group.

That old version of iText doesn't support Telugu. Support for writing systems such as Devenagari, Tamil, Telugu, etc... requires the pdfCalligraph add-on . This add-on is only available for iText 7. We have written a comprehensive white paper on the subject.

If you want to convert HTML with Telugu to PDF, you can't achieve this with Flying Saucer. As far as I know, the only tools that allow you to do this, are a combination of iText 7 , the pdfCalligraph add-on for Telugy support, and the pdfHTML add-on to convert HTML to PDF.

Update:

If you want to use pdfCalligraph, you need to add the following dependency:

<dependency>
    <groupId>com.itextpdf</groupId>
    <artifactId>typography</artifactId>
    <version>[1.0,)</version>
    <scope>compile</scope>
</dependency>

As pdfCalligraph is a closed source add-on, you also need to add our closed source repository to your list of repositories:

<repositories>
    <repository>
        <id>central</id>
        <name>iText Repository-releases</name>
        <url>https://repo.itextsupport.com/releases</url>
    </repository>
</repositories>

Finally, you need to introduce the license key mechanism (otherwise pdfCalligraph will throw an com.itextpdf.licensekey.LicenseKeyException or a java.io.FileNotFoundException:itextkey.xml ):

<dependency>
    <groupId>com.itextpdf</groupId>
    <artifactId>itext-licensekey</artifactId>
    <version>[2.0,)</version>
    <scope>compile</scope>
</dependency>

You need a license key ( KEY ), and you need to load that key like this:

LicenseKey.loadLicenseFile(new FileInputStream(KEY));

KEY contains the path to an XML file. This XML file is your license key. You can obtain such an XML file here: free trial .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM