2

how to show chinese word to pdf using jsp ?

when I using Jasper Studio to see the pdf

chinese word is no problem

but when I using JSP to show pdf

I get the error message

Font "kaiu" is not available to the JVM. See the Javadoc for more details.

how to fix it ?

Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
名宏 鄭
  • 115
  • 1
  • 5
  • 12
  • or [how-can-i-render-hindi-correctly-when-exporting-to-pdf](http://stackoverflow.com/questions/34287186/how-can-i-render-hindi-correctly-when-exporting-to-pdf) or [jasper-reports-pdf-doesnt-export-cyrillic-values](http://stackoverflow.com/questions/34041619/jasper-reports-pdf-doesnt-export-cyrillic-values/) – Petter Friberg Apr 13 '16 at 09:32

1 Answers1

1

You can create a Font extension jar with iReport and export it out and add it to your classpath and everything should be fine. See this blog post for an example: http://mdahlman.wordpress.com/2010/05/28/jaspersoft-v3-7-font-extensions/

Second option is copy fonts in reports related folder and create style tag, then map the style to component.

<style name="yourHeader" fontName="Verdana" fontSize="9" isBold="true" pdfFontName="reports/fonts/fontname.ttf" pdfEncoding="Cp1252" isPdfEmbedded="true"/>

PdfEncoding is required attribute.

        <textField isBlankWhenNull="false">
            <reportElement key="textField" style="yourHeader" x="1" y="1" width="200" height="20" />
            <textElement>
                <font isPdfEmbedded="true"/>
            </textElement>
            <textFieldExpression><![CDATA[$R{text}]]></textFieldExpression>
        </textField>

Font is available in your machine, but they aren’t registered as font extensions refer below link

http://www.cnblogs.com/keyliu/archive/2012/07/19/2600037.html

balamuruganv
  • 123
  • 6