Jump to content
We've recently updated our Privacy Statement, available here ×

Using System Fonts for Reports PDF Generation


cutebluangel
Go to solution Solved by Friendly User,

Recommended Posts

I have coded a report that utilizes the system font Times New Roman.

I did not include any font jars but is relying on the idea that Jasper Reports should be able to utilize system fonts.

I used the viewer to view the preview in Jasper Studio, the fonts correctly renders.

When I tried exporting it to PDF, the Font Properties of the generated output shows that it utilized the following font:

Helvetica
   Type: Type1
   Encoding: Ansi
   Actual Font: Arial
   Actual Font Type: TrueType

This is very far from the Times New Roman that I was expecting.

I also tried generating the report via a simple java program and set the logging to trace for the jasperreports class files.

A portion of the log file is pasted in https://pastebin.com/SnTptaHS.

It seems to show that it used java.awtFont using family = Times New Roman (lines 2-7 and lot of other lines). My test font set which is called Test Font seems to be replaced by font with family = Dialog (lines 18-24 and lines 13-36), which honestly, I expect parts of the reports set to the non-existing font set to go bonkers since I did not put the font extension jar in the class file.

So I'm wondering why it still used Helvetica which is the default PDF font.

 

O.S. Windows 10

Jasper Reports version: 6.4.3

 

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Do you mean the Times-Roman Standard Type 1 font? I suppose for this case and other Standard Type 1 PDF fonts it is workable. But what if it is fonts like Calibri or Comics Sans? We have no other way to utilize these system fonts than to include in font jars and link to the project classpath that generates my jasper reports?

Link to comment
Share on other sites

  • Solution

You can do that but you'll need to register extra fonts with the iText library. iText is used when exporting to PDF and it doesn't pay attention to the fontName unless the font can be found in the font extension. Considering the amount of effort it takes to register a font with iText or to create a font extension, I'd go with a Font Extension since it's much more streamlined. You can do that right in the studio.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...