我試圖使用字體,該字體未安裝在我的本地操作系統上,其編號爲JasperReports
。碧玉報告使用了這種方式:JasperReports:如何在應用程序類路徑中添加字體
<textField>
<reportElement x="0" y="0" width="137" height="20"/>
<textElement>
<font fontName="Corbel" size="12"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{something}]]></textFieldExpression>
</textField>
命名Corbel
字體導出爲一個字體擴展(使用iReport的),幷包含在文件(Corbel.jar),文件夾,我的系統上。 我這個擴展添加到應用程序的類路徑,使用的代碼如下:報告充滿
ClassLoader cl = new URLClassLoader(new URL[] {new URL("file:///D:/path/to/Corbel_jar_folder/")});
param = new HashMap();
param.put(JRParameter.REPORT_CLASS_LOADER, cl);
jasperReport = JasperCompileManager.compileReport("d:/path/to/Report_with_Corbel_font.jrxml");
jasperPrint = JasperFillManager.fillReport(jasperReport, param, new JREmptyDataSource());
後,我把它用JRPdfExporter
出口。但是,在結果pdf文件中,該元素沒有應用字體Corbel
。我沒有包含PDF導出,因爲我認爲問題在填充的地方。 我在JasperReports
中搜索並閱讀了許多與使用/包括字體(即字體擴展名)相關的帖子和問題;我仍然不知道錯誤或問題所在。 任何幫助將不勝感激。
預先感謝您! (對不起,代碼縮進,我希望我已經包含足夠的細節)