JasperReport export PDF report missing font error

Recently, when using JasperReport to print and export, "Font '宋体' is not available to the JVM. See the Javadoc for more details." After checking the environment over there, I found that the deployed Linux machine did not follow the Song Dynasty, and later found some information , using the following solutions:

(1) Download the Jasperreport project and enter the directory \demo\fonts\net\sf\jasperreports\fonts\dejavu

(2) Copy the Song Dynasty font file in the C:\WINDOWS\Fonts directory to In the above directory, and modify the suffix to simsun.ttf

(3) Modify the fonts.xml in the \demo\fonts\net\sf\jasperreports\fonts directory, add the fontFamily element, and configure the Song Dynasty information:

  <fontFamily name="宋体" >

       <normal>net/sf/jasperreports/fonts/dejavu/simsun.ttf</normal>

       <bold>net/sf/jasperreports/fonts/dejavu/simsun.ttf</bold>

       <italic>net/sf/jasperreports/ fonts/dejavu/simsun.ttf</italic>

       <boldItalic>net/sf/jasperreports/fonts/dejavu/simsun.ttf</boldItalic>

       < pdfEncoding>Identity-H</pdfEncoding>

       <pdfEmbedded>true</pdfEmbedded>

       <exportFonts>

           <export key="net.sf.jasperreports.html">'宋体', Arial, Helvetica, sans-serif</export>

           <export key="net.sf.jasperreports .xhtml">'宋体', Arial, Helvetica, sans-serif</export>

       </exportFonts>

</fontFamily>

(4) The font project in the demo\fonts directory is typed out of the jar package and placed in the project's WEB-INF/lib Directory

(5) Finally, add the configuration file jasperreports.properties to the root directory of the Web project, with the following contents:

net.sf.jasperreports.awt.ignore.missing.font=true net.sf.jasperreports.extension.registry.factory.simple .font.families=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory net.sf.jasperreports.extension.simple.font.families.dejavu=net/sf/jasperreports/fonts/fonts. xml
Finally, I explain according to my own understanding why this can solve the error of missing fonts, because the configuration file jasperreports.properties in the project root directory will be loaded at startup, and then I know what to do when JasperReport cannot find fonts when exporting , and we manually added the corresponding fonts to the project, so that the missing fonts can no longer be installed in the server. If there are other fonts in the produced jasper template, it can also be processed in the same way

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326904621&siteId=291194637