Showing posts with label jar. Show all posts
Showing posts with label jar. Show all posts

Monday, March 12, 2012

fonts problem in jasper report for pdf

when we export jaspert report to pdf format, we face problem with the font of the file. As, jasper report deal with its own true type font only for pdf. For this reason, we need to use the steps of font extension. This can be done following the steps below:

Ingredients: Jar file of jasperreports-fonts-v.v.v.(v stand for Version), true type fonts

1. Download the jasperreports-fonts-v.v.v(i.e jasperreports-fonts-4.0.1) jar file to modify according your requirements.
2.Right click on the jar file and select Extract to jasperreports-fonts-v.v.v.
3.At the root directory of the extracted folder, there is a properties file named: jasperreports_extension.properties

The file contains:
net.sf.jasperreports.extension.registry.factory.simple.font.families=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.dejavu=net/sf/jasperreports/fonts/fonts.xml

For the practise, here we will try to add the Times New Roman fonts to this jar. So, now we will have to add the following lines at the above file.
net.sf.jasperreports.extension.simple.font.families.timesnewroman=net/sf/jasperreports/fonts/fonts.xml

After adding we will get the file as:

net.sf.jasperreports.extension.registry.factory.simple.font.families=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.dejavu=net/sf/jasperreports/fonts/fonts.xml
net.sf.jasperreports.extension.simple.font.families.timesnewroman=net/sf/jasperreports/fonts/fonts.xml

4.Now, create the specific location to save the font collection. for this purpose, we create a directory in the location of ~/jasperreports-fonts-v.v.v\net\sf\jasperreports\fonts\. The name of the file will be timesnewroman for our case.

5. Now we need to add the collections of true type fonts at the above newly created location. Generally four files will be added as the representative of four categories: normal, bold, italic, bold italic.

6. Now its the time to modifying the fonts.xml file. We need to add the definition of the font to tis xml file. For our case, the definition will be as:

<fontFamily name="Times New Roman">
<normal>net/sf/jasperreports/fonts/timesnewroman/times.ttf</normal>
<bold>net/sf/jasperreports/fonts/timesnewroman/timesbd.ttf</bold>
<italic>net/sf/jasperreports/fonts/timesnewroman/timesi.ttf</italic>
<boldItalic>net/sf/jasperreports/fonts/timesnewroman/timesbi.ttf</boldItalic>
<pdfEncoding>Identity-H</pdfEncoding>
<pdfEmbedded>true</pdfEmbedded>
<exportFonts>
<export key="net.sf.jasperreports.html">'Times New Roman', Arial, Helvetica, sans-serif</export>
<export key="net.sf.jasperreports.xhtml">'Times New Roman', Arial, Helvetica, sans-serif</export>
</exportFonts>
<!--
<locales>
<locale>en_US</locale>
<locale>de_DE</locale>
</locales>
-->
</fontFamily>

7. after completion of customization, again we will make the jar from the raw files. Entering into the extracted folder, select all the files. right clcik and select the option Add to Archive. select the type to ZIP. At the end of the name, change the extension to .jar.

8. After that use this jar where you want.



--
For converting code to show on blog, i have used http://centricle.com/tools/html-entities/

Wednesday, February 22, 2012

Executing a JAR file using Windows Task Scheduler

Generally, when we click over a jar file , it executes. But if we are in need of executing a jar file using Windows Scheduler it invites some barriers(!).
We are not in need to do something incredible, just usingthe Windows Task Scheduler. . We need to customize the various prefrences for setting up the task in the windows scheduler.

Since a JAR file is not a Windows executable file, all you need to do is:

1. Type task in the run from the start menu(for windows 7).
2. from the action panel of the right side of the window, select Create task.
3. Filling all the parameters of General and Trigger panel, from the action panel
Set program or script to the location of java.exe from the specified location of the jre folder.
C:\Program Files\Java\jre6\bin\java.exe
Set add arguments option to something like the command line to execute the jar.
-jar D:\jarFileLocation\jarFile.jar