I was struggling a bit trying to bold fonts in the pdf generated by JasperReports.
Of course I set bold attribute in iReport and preview looked good, but when I was generating pdf using Java library, there was no sign of bold style.
Additionally, even I set DejaVu Sans font, in pdf output there was a Helvetica only.
I thought that upgrade JasperReports to 5.5 version would solve the case, but it didn't.
I've also tried attached external fonts like in this post by creating my own jar as a extension to iReport and adding it to classpath.
Next, I have tried to tell Jasper software that I want an embedded fonts in pdf file and set up default font name either in iReport or in Java code like below:
DefaultJasperReportsContext context = DefaultJasperReportsContext.getInstance(); JRPropertiesUtil.getInstance(context).setProperty("net.sf.jasperreports.default.font.name", "DejaVu Sans"); JRPropertiesUtil.getInstance(context).setProperty("net.sf.jasperreports.default.pdf.embedded", "true"); JRPropertiesUtil.getInstance(context).setProperty("net.sf.jasperreports.default.pdf.font.name", "DejaVu Sans");That didn't help either.
Eventually, it turned out that these few lines were the solution:
One extra dependency was sufficient to bold fonts working with JasperReports pdf!net.sf.jasperreports jasperreports-fonts 4.0.0
Fantastic solution!
ReplyDeleteThanksssss!!!
ReplyDeleteAwesome, Thank you
ReplyDeletesuper excellent solution
ReplyDeleteMaven unable to find jasperreports-fonts ? possible reason of this issue
ReplyDelete?
Awesome, thx !!!
ReplyDelete