PDF Printing Arial not bold?

Hi, just saw that my whole report (one main and eleven subreports) are not bold in any of my text-fields. I am required to use Arial if possible, but since Arial seems not to get used when exporting to pdf and font weight seems to get discarded if that happens, I switched to Sans Serif.

Is there any way to use Arial font with bold font weight when exporting to pdf without workarounds? Just a clean solution? If not I'd be very thankful for any explanation on why it is that way as I need to justify my descisions and it'd help me a lot ^_^

MiditecReportDev's picture
Joined: Mar 6 2016 - 11:42pm
Last seen: 4 years 6 months ago
I have the same problem. I've created extensions for Arial Bold, Arial Italic and Arial Bold Italic, using the corresponding WIndows font files. They show up as expected in the Font dropdown. I then exported them to a jar. I looked in the jar file and everything looks good. The fontsfamily.xml file contains:
<?xml version="1.0" encoding="UTF-8"?>
  <fontFamily name="Arial-Italic">
  <fontFamily name="Arial-Bold">
  <fontFamily name="Arial-Bold-Italic">
In my case I'm using it in a web app, so it's with the rest of  my jars in WEB-INF/lib. For a fixed text element which I want in Arial Italic, I selected "styled" in the markup dropdown, and added a <style> element to the text:
     <reportElement style="Large" x="30" y="40" width="126" height="30" uuid="7e908695-0594-4452-9a82-471ef38d7281">
         <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
     <textElement markup="styled"/>
     <text><![CDATA[<style pdfFontName="Arial-Italic" isPdfEmbedded="true">Public Security Division</style>]]></text>
But when I try to generate the PDF in my web app, I get an exception:
net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font: 
pdfFontName: Arial-Italic
pdfEncoding: Cp1252
isPdfEmbedded : true
    at net.sf.jasperreports.engine.export.JRPdfExporter.getFont(JRPdfExporter.java:2278)
    at net.sf.jasperreports.engine.export.JRPdfExporter.getChunk(JRPdfExporter.java:2069)
I'm at a loss. Any ideas?
RTThomas - 6 years 11 months ago

1 Answer:

The recommended approach is to create a font extension (with Arial or other font files) and specify that the fonts are to embedded in PDFs.

Jaspersoft Studio can be used to create the font extension jar.



lucianc's picture
Joined: Jul 17 2006 - 1:10am
Last seen: 2 hours 8 min ago