I am trying to use a font, that is not installed on my local OS, with a JasperReports
. The jasper report uses in this way:
<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>
The font named Corbel
was exported as a font extension (using iReport) and is contained in file (Corbel.jar), in folder, on my system.
I add this extension to the classpath of the application, using a code as follows:
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());
After the report is filled, I export it using a JRPdfExporter
. However, in the result pdf file, the element does not have the Corbel
font applied. I have not included the pdf exporting, because I think that the problem is somewhere with the filling.
I have searched and read numerous posts and questions related to using/including fonts (i.e.font extensions) in JasperReports
; still I am not aware of where the mistake or the problem resides.
Any help would be greatly appreciated.
Thank you in advance! (sorry for the bad code indentation and I hope I have included enough details)