I am using Dynamic Reports 6.0.0 and Java 8. I am generating a pdf file using "Helevetica-Neue1" font. My project is a simple maven project without using any frameworks. I have placed the "helvetica-neue1.ttf" file in "src/main/resources/font/" folder.
The following configuration is provided in "fonts.xml" file which is located in "src/main/resources" folder.
<fontFamily name="Helvetica">
<normal>font/helvetica-neue1.ttf</normal>
<pdfEncoding>Identity-H</pdfEncoding>
<pdfEmbedded>true</pdfEmbedded>
</fontFamily>
The following configuration is provided in "dynamicreports-defaults.xml" file which is located in "src/main/resources" folder.
<DynamicReports>
<font fontName="Helvetica" />
</DynamicReports>
The code written for it is :
StyleBuilder title = stl.style().setHorizontalTextAlignment(HorizontalTextAlignment.LEFT).setFontSize(12).setFontName("Helvetica");
The configurations are found to be correct since the report is getting generated with the required font when it is executed as a standalone program using public static void main() with dummy data.
But the same report is not getting generated when the project is deployed in weblogic server. There is no exception thrown but the server execution is stopped abruptly after the ".setFontName("Helvetica") line is executed.
The project is deployed as a jar file within another war file. This war file is deployed in weblogic server. The required dependencies of dynamic reports jar is added in pom.xml.
<dependency>
<groupId>net.sourceforge.dynamicreports</groupId>
<artifactId>dynamicreports-core</artifactId>
<version>6.0.0</version>
</dependency>
My guess is that it is not able to load the ttf file of the font from the required path. If default fonts are used, report is getting generated successfully.
Please let me know the solution for this issue. Thanks in advance.
The solution for this is to deploy the project containing the code for generating the dynamic report as a war file. In my case, the project containing the code for generating the report was present in a jar file which was present in a war file. So, when the war file was deployed, it was unable to read the font from the required location. When the same jar file was deployed as a war file individually, the required fonts were reflected in the generated pdf.