Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue in Jasper iReport generated PDFs in Chrome

Tags:

I am generating a document in Chinese, as well as several other languages, using conditional formatting in Jasper iReport 5. I have iTextAsian.jar in my lib folder. The generated PDF displays Chinese in IE, Firefox, Adobe, Foxit but not Chrome.

In Chrome, all the Chinese characters are missing. I have isPdfEmbedded set to true. Here is the style I am assigning to the Chinese fields. Am I not embeddeding?

    <style name="DynamicFont" isDefault="true" forecolor="#000000" backcolor="#FFFFFF" isBlankWhenNull="false" fontName="SansSerif" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" isPdfEmbedded="true">
        <conditionalStyle>
            <conditionExpression><![CDATA[$F{locale}.toString().compareToIgnoreCase("am_ET") == 0]]></conditionExpression>
            <style mode="Transparent" forecolor="#000000" fontName="SansSerif" pdfFontName="Amharic-Eng-Regular.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
        </conditionalStyle>
        <conditionalStyle>
            <conditionExpression><![CDATA[$F{locale}.toString().compareToIgnoreCase("vi_VN") == 0]]></conditionExpression>
            <style mode="Transparent" forecolor="#000000" fontName="SansSerif" pdfFontName="customizationsFonts/Roboto-Regular.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
        </conditionalStyle>
        <conditionalStyle>
            <conditionExpression><![CDATA[$F{locale}.toString().compareToIgnoreCase("zh_CN") == 0]]></conditionExpression>
            <style mode="Transparent" forecolor="#000000" fontName="SansSerif" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H" isPdfEmbedded="true"/>
        </conditionalStyle>
    </style>

Is this a Chrome issue or something about the way I am generating the PDF with iReport?

Thank you very much for your time and patience.

John

-- edit --

Here is an example file: [example.pdf]: http://www.easleybooks.com/example.pdf

like image 233
John Avatar asked Dec 18 '19 16:12

John


1 Answers

I assume there is no error in your code because If any errors exist, other browsers also can't to display your report correctly. There for you can try these steps to avoid your issue.

  1. Some of your chrome extensions interrupt your report generation. There for disable your chrome extensions.
  2. Open your Chrome developer tools and run your code again and see if there are any error generate in console.
  3. According to this discussion there was a bug exist in chrome that prevent Chinese and Japanese letters to display. There for update your chrome to it latest.
  4. Try to set up setting in the latest chrome by Custom and Control (Wrench icon) > Tools > Encoding >select Unicode (UTF-8)

If these solutions not worked try to update jasper to it latest. I saw there are problems with older versions of jasper when viewing Chinese and Japanese.


Update -: You have used your Chinese font as pdfFontName="STSong-Light" in your code. Try to use any Chinese simplified font to print your pdf because in Firefox your Chinese languages understand as collection of two fonts(Microsoft YaHei and Yu Gothic) , but in Chrome it cannot understand the language even if acrobat extension is enabled. There for you have to change your Chinese font name in your pdf.

like image 56
Kalana Avatar answered Oct 02 '22 15:10

Kalana