Jasper Reports PDF Doesn't Export Cyrillic Values

Jasper Reports PDF doesn't export cyrillic values

Jasper report uses iText and always when a char is not rendered in pdf this should be the checklist:

  1. Is my actual .tff supported (OpenType) and can the font actually render the character. Not all fonts render
    all characters in UTF-8, see How can I test if my font is rendered correctly in pdf?
  2. Do I pass correct encoding to iText. In doubts (or in general) use the encoding Identity-H this is recommend for newer PDF standards and gives you the ability to mix different encoding.
  3. Is my font embedded so that if I share the pdf also computers not having this font can display the content?

How can I ensure this is JasperReport?

The deprecated method was to set attributes on the textElement

<textElement>
<font pdfFontName="Helvetica" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
<paragraph lineSpacing="Single"/>
</textElement>

The current non deprecated method v 3-6, is to add Font Extensions and this is easily achieved by using tools like iReport or JasperSoft Studio that can generate a .jar of your font extension so that you can include it in your classpath directly.

How to generate font extension .jar using iReport or JasperSoft Studio.

EDIT: The problem of OP was 1 on checklist (.ttf font could not render), but surely he should consider both 2 and 3 using non deprecated method.

How to fix Unicode font error in JasperReport 6.0.20?

You need to register the fonts in Jaspersoft Studio under Preferences/Jaspersoft Studio/Fonts with the PDF embedding flag checked and Identity-H as PDF encoding.

Jaspersoft Studio font

If you want to generate reports in an application that uses the JasperReports library, you'll have to export the fonts as jars and include them in your application's classpath.

You should also check that the license under which you use the fonts allows you to embed them in generated documents.

Why is jasper generated report not showing cyrillic (bulgarian) in Java?

I finally achieved it. I needed to change these two lines in the xml:

<pdfEncoding><![CDATA[Identity-H]]></pdfEncoding>
<pdfEmbedded><![CDATA[true]]></pdfEmbedded>

I changed in the Java code the BaseFont constant BaseFont.CP1252 in these lines:

new PdfFont(pathArialFont, BaseFont.IDENTITY_H, true);

and entered the text in my ISO8859-1 properties file like this:

label=\u0424\u0430\u043A\u0442\u0443\u0440\u0430\r\n\u041E\u0440\u0438\u0433\u0438\u043D\u0430\u043B

And in the designer mode I edited the field to font "Arial Unicode MS" and checked "Pdf embedded" with Pdf Encoding "Identity-H".

Static text cutting off while exporting reports to pdf in Linux Deployments using Jasper Reports

In order to resolve it, we included the Arial font in jasper-font jar and changed the font from Helvetica to Arial in reports.

Once done, Reports started rendering fine in Linux and Windows region since Arial font TTF files were part of the war thru jasper-font jar.



Related Topics



Leave a reply



Submit