Jump to content
Changes to the Jaspersoft community edition download ×

Load fonts (ttf) inside a jar


vassilis13

Recommended Posts

Helloall,

I have created a project in netbeans using jasperreports. jrxml and jasper files exist in folder app.gui. In all jrxml files I have pdfFontName="arial.ttf" . In Netbeans in project properties I have added folder C:\Project\lib\Fonts. In this folder I have copied all ttf files. In netbeans the project and the reports are executed fine.

However, when I try to execute the jar file in dist folder there is always problem in producing reports even if I try everything possible combination. The manifest file in app.jar contains entry lib/Fonts. The structure in netbeans dist folder is

dist (Folder)

       App.jar

      lib(Folder)

         (other jars here)

          Fonts (Folder)

               All ttfs here

 

The exception I get   is "Could not load the following font: .... etx" from JRRuntimeExceptionReport.

 

I would appreciate any help.

Thanks

Vassilis

          

 

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

Bundle the ttf files in a Java archive file:

$ jar -tvf font-liberationsans.jar
   238 Sun Jun 20 23:25:58 PDT 2010 jasperreports_extension.properties
   312 Sun Jun 20 23:25:58 PDT 2010 fonts/fontsfamily1277101559240.xml
 25436 Sun Jun 20 23:25:58 PDT 2010 fonts/LiberationSans-Regular.ttf
 19472 Sun Jun 20 23:25:58 PDT 2010 fonts/LiberationSans-Bold.ttf

Then add the directory of the JAR file to the java.ext.dirs path parameter when invoking the Java Virtual Machine. For example:

java -Djava.ext.dirs=./software/climate/java/fonts com.class.Main

 

Link to comment
Share on other sites

Hello,

Thanks for your feedback. In that way my application also works. The problem is that I do not want to extract the jar file and execute the class.I want the jar to be executed: java -jar App.jar.

With the above command I cannot pass JVM parameters to the commandline and I have to insert the path of the fonts to manifest file. Unfortunately, this does not seem to work, and that's why I posted.

Thanks,

Vassilis

 

 

 

 

 

 

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