Spring Boot application generates PDF reports with JasperReport and uses different custom fonts, which support multiple language printing. This project is maintained by Maven.
Language and font list:
- Arabic(ar): Tajawal
- Hindi(hi): Tiro Devanagari Hindi
- Japanese(ja): Sawarabi Gothic
- Korean(ko): Nanum Gothic
- Thai(th): Sarabun
- Traditional Chinese(zh_tw): 源真ゴシック (げんしんゴシック)
Check jrxml examples and PDF reports on the reference directory. Since all text in demo reports is translated by Google Translate, there may have some strange words. If you can correct those issues, feel free to send a pull request.
Check more detail in my blog post JasperReports with Spring(in Chinese).
The project template is generated by https://start.spring.io/ and jrxml is designed by TIBCO Jaspersoft® Studio.
- Spring Boot 2.7.4
- JasperReports 6.20.0
- TIBCO Jaspersoft® Studio 6.20.0
- Source .jrxml Version: JasperReport 6.20.0
- Compiler Settings: 6.20.0
-
Run with docker compose
docker-compose up -d
-
Send POST request with curl to print PDF report
# chose language you want bash scripts/ar.sh bash scripts/hi.sh bash scripts/ja.sh bash scripts/ko.sh bash scripts/th.sh bash scripts/zh_tw.sh
- Prepare the custom font with TTF, SVG, WOFF, or EOT format, since Jasper Font Extension only supports these formats.
- Google Font provides a lot of open source fonts. Some fonts will be provided in TTF format directly, if not you can find the TTF file in google font GitHub repository.
- Open the
Fonts
tab in TIBCO Jaspersoft Studio preference and click add button to add a new font.- Fill the
Font Family
dialog and theFamily Name
will be the font name used in jrxml. - In the PDF details block, chose PDF Encoding as
Identity-H (Unicode with horizontal writing)
and checkEmbed this font in PDF document
.
- Fill the
- After back to the
Fonts
tab in preference, export the custom font jar. - Add the font jar to
lib
directory and add dependency in pom.xml.
Reference:
- Spring Boot with Docker
- "mvnw" won't work on docker-pipeline with the "maven" image because docker-pipeline doesn't honor docker image entrypoint
- Custom Font with the Font Extension
- 用 Java 產出中文的 JasperReports PDF
- JASPER REPORTS WITH SPRING BOOT
- Jasper Reports using unavailable fonts
- jasper综合使用-javabean结合实际业务-解决PDF中文
- Spring Boot 打包 external jar 解決方案