0

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.

1 Answers1

3

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.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
  • 2
    Aditionally, they are using iText 4.2.0, which is a version that was never released by iText Software but by ymasory/InProTopia. – Amedee Van Gasse May 09 '17 at 08:12
  • Could you please explain more... tried with itext7 generating telugu pdf. Still we are getting content with the gaps. – user1896803 May 10 '17 at 06:20
  • @user1896803 If you get the content with the gaps, you are not using pdfCalligraph. Note that pdfCalligraph is *closed source*. It requires a trial license if you want to use it. Did you get a trial license? Search for the word `pdfCalligraph` in chapter 2 of the tutorial: http://developers.itextpdf.com/content/itext-7-building-blocks/chapter-2-working-rootelement – Bruno Lowagie May 10 '17 at 06:24
  • Tried for trial license but unable to find that. Could you please let us know where to find the trail version and what are all the jars required to get the Telugu language in PDF and it will be helpful to us if you provide some sample piece of code. Thanks in advance. – user1896803 May 10 '17 at 07:08
  • I'll put that in my answer. It's too much to put in a comment section. – Bruno Lowagie May 10 '17 at 07:15