Home > Java > javaTutorial > body text

Why Are Cyrillic Characters Corrupted When Exporting Jasper Reports to PDF?

Susan Sarandon
Release: 2024-11-13 15:55:02
Original
880 people have browsed it

Why Are Cyrillic Characters Corrupted When Exporting Jasper Reports to PDF?

Troubleshooting Cyrillic Character Export Issues in Jasper Reports

Jasper Reports encounters challenges displaying Cyrillic values when exported to PDF format. While they appear correctly when exported as Excel, the text is corrupted in PDF. This issue stems from the underlying iText library utilized by Jasper Reports.

iText Character Rendering Considerations

To address this problem, consider the following steps:

  1. Ensure Font Compatibility: Verify that the TrueType Font (TTF) used supports Cyrillic characters and can render them properly in PDF format.
  2. Use Correct Encoding: Pass the correct encoding parameter to iText. For comprehensive compatibility, use "Identity-H" encoding, which allows for the inclusion of various character encodings.
  3. Embed the Font: Ensure that the font is embedded in the PDF document to allow viewing on systems that may not have the font installed locally.

JasperReport Configuration

To implement these changes in Jasper Reports:

  1. Deprecated Method: (deprecated in Jasper Reports versions 3 and above)

    • Define font attributes in the text element:
    <textElement>
      <font pdfFontName="Helvetica" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
      <paragraph lineSpacing="Single"/>
    </textElement>
    Copy after login
  2. Recommended Method: (for versions 3 and above)

    • Utilize Font Extensions: Generate a .jar file of your font extension using tools like iReport or JasperSoft Studio. Include this .jar file in your classpath.

By addressing these considerations, you can resolve the issue of missing Cyrillic values when exporting Jasper Reports to PDF format.

The above is the detailed content of Why Are Cyrillic Characters Corrupted When Exporting Jasper Reports to PDF?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template