Jump to content
Changes to the Jaspersoft community edition download ×

supplying font in webapp for pdf

Recommended Posts

By: Zsolt Berentey - zberentey

supplying font in webapp for pdf

2003-03-20 11:36

I am probably a very newbie to the subject, although I have read through all the threads concerning this issue. Still, I have a problem of using non built-in fonts with PDF. I'd like to supply the fonts (both t1 and ttf) with the web-app, and wouldn't like to use absolute paths in the report file.


Can someone tell me where to put the font files (the exact location realtive to the WEB-INF directory for example) and what to put into the pdffontname attribute?


I am using tomcat.








By: Teodor Danciu - teodord

RE: supplying font in webapp for pdf

2003-03-21 00:56




Put the TTF files in the Web application classpath.

This means you have to put them under the

WEB-IN/classes directory.


If your TTF file is placed placed here:




then in the XML you write




I hope this helps.







By: Zsolt Berentey - zberentey

RE: supplying font in webapp for pdf

2003-03-21 09:24



Thanks for the answer. I was doing exactly this, but I used a lowercase extension while the file had an uppercase one. While the File object found it when using an absolute path (win2k), the resource loader could not :))

So, this solved the problem but raised another. Now the resource is found, but I get an exception:

com.lowagie.text.DocumentException: Two byte arrays are needed if the Type1 font is embedded.

at com.lowagie.text.pdf.Type1Font.(Unknown Source)

at com.lowagie.text.pdf.BaseFont.createFont(Unknown Source)

at dori.jasper.engine.export.JRPdfExporter.exportText(JRPdfExporter.java:1009)



What's missing?








By: Zsolt Berentey - zberentey

RE: supplying font in webapp for pdf

2003-03-21 11:47

Found way to patch it. Can you look at it Teodor?

It should be put into dori.jasper.engine.export.JRPdfExporter:exportText() line 996


if (baseFont == null)


byte[] bytes = null;

byte[] pfb = null;




bytes = JRLoader.loadBytesFromLocation(jrFont.getPdfFontName());

if (jrFont.getPdfFontName().toLowerCase().endsWith(".afm")) {

pfb = JRLoader.loadBytesFromLocation(jrFont.getPdfFontName().substring(0, jrFont.getPdfFontName().length() - 3) + "pfb");




catch(JRException e)


throw new JRException("Could not load font from location : " + jrFont.getPdfFontName());



baseFont =
















By: Paulo Soares - psoares33

RE: supplying font in webapp for pdf

2003-03-21 16:51

The last version of iText tries to load the font from a resource if it's not found as a file.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...