Exporting Cyrillic Values in Jasper Reports PDF
When exporting a Jasper report to PDF, users may encounter an issue where Cyrillic characters fail to display correctly. This discrepancy occurs despite the characters being displayed accurately when exported to Excel.
To resolve this issue, it is crucial to ensure that the font used supports Cyrillic characters and that the correct character encoding is applied.
Code Optimization
The following code parameters should be included when exporting to PDF:
e.setParameter(JRPdfExporterParameter.JASPER_PRINT, jasperPrint); e.setParameter(JRPdfExporterParameter.OUTPUT_STREAM, outStream); e.setParameter(JRPdfExporterParameter.OUTPUT_FILE_NAME, NAME);
Additionally, specify the character encoding using the following parameter:
e.setParameter(JRPdfExporterParameter.CHARACTER_ENCODING, "UTF-8");
Font Considerations
It is important to note that the font used in the report must support Cyrillic characters and must be embedded into the PDF to ensure proper display on systems that may not have the font installed.
Recommended Approach
Jasper Reports utilizes iText under the hood. To ensure optimal handling of Cyrillic characters, adhering to the following checklist is recommended:
- Verify that the selected TrueType Font (TTF) supports the required Cyrillic characters.
- Employ the correct character encoding, such as "Identity-H."
- Embed the font into the PDF to facilitate display on systems without the font installed.
Deprecated Method:
Previously, the following deprecated method could be used to set attributes on the textElement:
<textelement> <font pdffontname="" pdfencoding="" ispdfembedded=""></font> <paragraph linespacing=""></paragraph> </textelement>
Non-Deprecated Method (v3-6):
In more recent versions, the preferred approach involves adding Font Extensions, which can be generated using tools like iReport or JasperSoft Studio. These extensions enable the inclusion of font resources in the classpath, ensuring proper display of Cyrillic characters.
The above is the detailed content of How to Correctly Display Cyrillic Characters in Jasper Reports PDFs?. For more information, please follow other related articles on the PHP Chinese website!

Start Spring using IntelliJIDEAUltimate version...

When using MyBatis-Plus or other ORM frameworks for database operations, it is often necessary to construct query conditions based on the attribute name of the entity class. If you manually every time...

Java...

How does the Redis caching solution realize the requirements of product ranking list? During the development process, we often need to deal with the requirements of rankings, such as displaying a...

Conversion of Java Objects and Arrays: In-depth discussion of the risks and correct methods of cast type conversion Many Java beginners will encounter the conversion of an object into an array...

Solutions to convert names to numbers to implement sorting In many application scenarios, users may need to sort in groups, especially in one...

Detailed explanation of the design of SKU and SPU tables on e-commerce platforms This article will discuss the database design issues of SKU and SPU in e-commerce platforms, especially how to deal with user-defined sales...

How to set the SpringBoot project default run configuration list in Idea using IntelliJ...


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version
Useful JavaScript development tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.