Home  >  Article  >  Java  >  Why Are Cyrillic Characters Corrupted When Exporting Jasper Reports to PDF?

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

Susan Sarandon
Susan SarandonOriginal
2024-11-13 15:55:02875browse

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>
  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!

Statement:
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