Jasper report can't generate PDF with CJK when is deployed

0

When I run Spring Framework Application from IntelliJ IDEA everything work fine and I'm able to generate Jasper Report with Chinese text. But as soon as I build and deploy WAR to Tomcat I can't generate report with following exception

net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font: 
pdfFontName: Arial Unicode MS
pdfEncoding: Identity-H
isPdfEmbedded : false
    net.sf.jasperreports.engine.export.JRPdfExporter.getFont(JRPdfExporter.java:2757)
    net.sf.jasperreports.engine.export.JRPdfExporter.getChunk(JRPdfExporter.java:2540)
    net.sf.jasperreports.engine.export.JRPdfExporter.getPhrase(JRPdfExporter.java:2509)
    net.sf.jasperreports.engine.export.SimplePdfTextRenderer.renderParagraph(SimplePdfTextRenderer.java:149)
    net.sf.jasperreports.engine.export.AbstractTextRenderer.render(AbstractTextRenderer.java:373)
    net.sf.jasperreports.engine.export.SimplePdfTextRenderer.render(SimplePdfTextRenderer.java:111)
    net.sf.jasperreports.engine.export.JRPdfExporter.exportText(JRPdfExporter.java:2870)
    net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:1275)
    net.sf.jasperreports.engine.export.JRPdfExporter.exportFrame(JRPdfExporter.java:3951)
    net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:1280)
    net.sf.jasperreports.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:1204)

I have added Arial Unicode MS to my project in a following way:

enter image description here

jasperreports_extension.properties:

net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.myfamily=report/fonts/fonts.xml

report/fonts/fonts.xml:

<?xml version="1.0" encoding="UTF-8"?>
<fontFamilies>
    <fontFamily name="Arial Unicode MS">
        <normal><![CDATA[report/fonts/ARIALUNI.TTF]]></normal>
        <pdfEncoding>Identity-H</pdfEncoding>
        <pdfEmbedded><![CDATA[false]]></pdfEmbedded>
    </fontFamily>
</fontFamilies>

Jasper Report dependecy:

<dependency>
    <groupId>net.sf.jasperreports</groupId>
    <artifactId>jasperreports</artifactId>
    <version>6.12.2</version>
</dependency>

coppied form StackOverFlow - https://stackoverflow.com/questions/63092148/jasper-report-cant-generate...

oleh.kurpiak's picture
Joined: Jul 25 2020 - 11:14am
Last seen: 1 month 3 weeks ago

0 Answers:

No answers yet
Feedback