Java – Bold style doesn’t work in pdf output

jasper-reportsjavapdf

I'm building a few report using iReport 5.1.0 and JasperReports 5.0.0. Now my trouble is that bold style is not appearing in pdf output. If I have stylized text (for example, "<b>My Text</b>"), the bold parts appear bold in the report's output, but not in the pdf. The only way I can get bold in pdf is to force the pdf font for that element to be a bold font (pdfFontName="Helvetica-Bold" for example), but that bolds the entire string and does not allow me to control it via the style markup <b>.

I'm exporting the pdf file in this way:

JRPdfExporter exp = new JRPdfExporter();
exp.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, namefileToExport);
exp.exportReport();

How can I do?

Best Answer

https://mvnrepository.com/artifact/net.sf.jasperreports/jasperreports-fonts/6.0.0

<!-- https://mvnrepository.com/artifact/net.sf.jasperreports/jasperreports-fonts -->
<dependency>
    <groupId>net.sf.jasperreports</groupId>
    <artifactId>jasperreports-fonts</artifactId>
    <version>6.0.0</version>
</dependency>

adding this dependency to the pom.xml should be enough to fix the problem