Embedding fonts in jasper reports

As it’s not guaranteed that all users have the same set of fonts, it’s a good idea to embed these fonts into the created PDF-Files, especially if it’s a more or less exotic font. The following example will quickly show the few steps required to accomplish this task.

Registering the font(s)

Basically all you need to do is to create two configuration files. The first is the jasper_extension.properties in the root directory of your java source. This file will point to the actual XML-File registering the desired fonts.

Next we have to register the actual font and reference the actual True-Type-Fonts. The most important part here, of course, is to let jasper know that the font has to be embedded into the PDF-File.

Using the font in the report

Now we have registered a font in jasper, we just need to reference it within the actual report.

Finally generate the report. No special setup required here.

Example Code

References

3 thoughts on “Embedding fonts in jasper reports”

    1. Please explain your problem more detailed. I currently don’t see a reason for images with a coding problem. 😀

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.