java 如何在 jasperreports 中安装新字体

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14831465/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 17:32:36  来源:igfitidea点击:

how to install new fonts in jasperreports

javafontsjasper-reports

提问by Yuvaraj

I am using jasperreport with PHP. i have a problem with installing new fonts i had installed new fonts in jasper report by using the following steps.

我在 PHP 中使用 jasperreport。我在安装新字体时遇到问题 我已通过使用以下步骤在 jasper 报告中安装了新字体。

  1. Edited jasperreports_extension.properties

    added the following line

  1. 已编辑 jasperreports_extension.properties

    添加了以下行

net.sf.jasperreports.extension.simple.font.families.Mistral=net/sf/jasperreports/fonts/fonts.xml

net.sf.jasperreports.extension.simple.font.families.Mistral=net/sf/jasperreports/fonts/fonts.xml

  1. in net\sf\jasperreports\fonts\fonts.xmli added the following line
  1. net\sf\jasperreports\fonts\fonts.xml我添加了以下行

I am getting the following error

我收到以下错误

Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: Invoke failed: [[c:JasperExportManager]]->exportReportToPdfFile((o:JasperPrint)[o:JasperPrint], (o:String)[o:String]). Cause: net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font : pdfFontName : Mistral pdfEncoding : Cp1252 isPdfEmbedded : false VM: 1.6.0_24@http://java.sun.com/" at: #-18 net.sf.jasperreports.engine.export.JRPdfExporter.getFont(JRPdfExporter.java:1961) #-17 net.sf.jasperreports.engine.export.JRPdfExporter.getChunk(JRPdfExporter.java:1725) #-16 net.sf.jasperreports.engine.export.JRPdfExporter.getPhrase(JRPdfExporter.java:1694) #0 /mount1/imeddoc/dev/JasperReports/includes/javabridge.php(338): java_ThrowExceptionProxyFactory->getProxy(12, '@V', 'Could not load ...', true) #1 /mount1/imeddoc/dev/JasperReports/includes/javabridge.php(495): java_Arg->getResult(true) #2 /mount1/imeddoc/dev/JasperReports/includes/javabridge.php(501): java_Client->getWrappedResult(true) #3 /mount1/imeddoc/dev/JasperReports/includes/javabridge.php(705) in /mount1/imeddoc/dev/JasperReports/includes/javabridge.php on line 301 

can anyone help me to solve this issue please

任何人都可以帮我解决这个问题吗

回答by Yuvaraj

I solved it using the option in ireport. To install a new font in jasperreport , install that in ireport and Export to jar file and then replace the jar file in your jasper project. to install a font in ireport , go to tools -> options -> fonts and click on install fonts. follow the steps and you will now install new fonts in ireport. please dont forget to check embed this font in pdf.

我使用 ireport 中的选项解决了它。要在 jasperreport 中安装新字体,请将其安装在 ireport 中并导出到 jar 文件,然后替换 jasper 项目中的 jar 文件。要在 ireport 中安装字体,请转到工具 -> 选项 -> 字体并单击安装字体。按照步骤操作,您现在将在 ireport 中安装新字体。请不要忘记检查在 pdf 中嵌入此字体。

Now to export the fonts , go to tools -> options -> fonts and then from the list of availble fonts please select the fonts you needed and then click Export as extension . which wil export the fonts as jar file. now replace the jar file in jasperreport library .

现在要导出字体,请转到工具 -> 选项 -> 字体,然后从可用字体列表中选择您需要的字体,然后单击导出为扩展名。它将字体导出为 jar 文件。现在替换 jasperreport 库中的 jar 文件。