Home > JasperReports > Embedding fonts into PDF generated by JasperReports

Embedding fonts into PDF generated by JasperReports

This post has moved here: http://javaskeleton.blogspot.com/2010/12/embedding-fonts-into-pdf-generated-by.html

Advertisements
  1. December 24, 2010 at 02:43

    Good article. I think font extensions are not understood or used as well as they should be, so it’s nice to see things like this.
    By the way, there is no “s” in iReport.

    • December 24, 2010 at 09:12

      mdahlman :

      Good article. I think font extensions are not understood or used as well as they should be, so it’s nice to see things like this.
      By the way, there is no “s” in iReport.

      Thanks. I checked your blog and it looks really good. I see you already did an article on this subject (for the JasperReports server) yourself. People interested in JasperReports should defenately check his blog at https://mdahlman.wordpress.com/!

  2. December 29, 2010 at 10:11

    Thanks, that article saved my day! I was searching arround for days and did not find a suitable solution to this Problem. I could not beleive that a Report tool like Jasper cannot handle bold fonts.

    • December 29, 2010 at 11:06

      Hi Christoph,

      As you can see Jasper Reports can handle bold fonts, you just have to know how to configure it :-). That’s the main problem with Jasper Reports: the documentation. There is the ultimate guide that’s very good, but unfortunately it’s not free. If you don’t use Jasper Reports commercially you’re on your own.

  3. nikos
    January 12, 2011 at 10:58

    Thanks a lot. I finally made it work!

  4. Andy
    March 10, 2011 at 04:11

    I have tried both methods, but they are only applicable if you are using Java 1.5 while I am using Java 1.4. Do we have other way to resolve this issue?

    • March 14, 2011 at 14:06

      Hi Andy,

      First of all I would definitely recommend upgrading to a newer java version: 1.4 is starting to get pretty old. I suppose you don’t have a choice or you would already have done so.
      Can you tell me exactly which part doesn’t work on java 1.4? Is it the font extension, iReport, JasperReport…? You could try mapping the fonts directly in your report xml file, as follows:

      <font fontName=”My Font” ispdfembedded=”true”
      pdffontname=”path/to/myfont.ttf”/>

      I haven’t tried this though, so I don’t know if it will work…

  5. hema
    March 30, 2011 at 08:26

    Hi,

    I have created the fonts jar file and kept in the classpath.
    After this do we need to do any changes in the jrxml file like setting “PDFembedded = true”..please clarify

    Regards,
    Hema

    • March 30, 2011 at 11:07

      Hi,

      You don’t have to modify your jrxml file if you use the font extension, that was the old approach. The new approach is to use the font extension. All you have to do is make sure that the font name used in your jrxml file is the same as the one you define in the fontfamily.xml file.

  6. hema
    March 30, 2011 at 09:07

    hi,

    my concern is how can we make sure that the jasper report is using the fonts from fonts jar file or from windows/unix environment.

    Please clarify..

    Thanks in advance,
    Hema.

    • March 30, 2011 at 11:06

      Hi,

      Jasper reports will not pick up the fonts from the windows/unix environment. This is the reason you need the font extension. iReport DOES pick up the fonts from the OS, and that’s the reason your report looks ok in iReport but not in JasperReport.

      In the fonts.jar file is a file called jasperreports_extension.properties. Jasper reports will automatically pick up this file and read it out. It will the find your font definition file (the fontfamily.xml file or whatever you called it) and get the fonts from that file. It will all be automatic, all you need to do is add the jar file to your classpath.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: