Friday, 29 July 2016

How to add custom fonts in Jasper of GGTS

Hi,

Before going to add, first download any one of the font from google. i downloaded one of the font from http://www.1001freefonts.com/

goto your project workspace,

Step 1: Add Font in Jasper

windows -> prefferences -> jaspersoft studio -> Fonts ->  Add

place family name as font name

browse true type as font file

check the checkbox of Embed this font in PDF doucment

and click Finish and then OK




Step 2: Create jar file of given font through iReport Designer tool

install and run iReport Designer tool

goto tools -> options -> iReport -> Fonts

Click Install Font, 





Browse font location and then click next

place family name as font name

check the checkbox of Embed this font in PDF doucment




and then click Finish

the given font showed in Fonts tab



select that font, click on Export as extension




Save with .jar, then jar is saved in selected location.

then close iReport Designer.

Step 3: Add jar file to GGTS

add jar file in lib folder of ggts

place these 3 lines before calling jasper report

String defaultPDFFont = "LittleLordFontleroyNF";
DefaultJasperReportsContext context = DefaultJasperReportsContext.getInstance();
JRProperties.setProperty("net.sf.jasperreports.awt.ignore.missing.font", "true");
JRProperties.setProperty("net.sf.jasperreports.default.font.name", defaultPDFFont);



extract jar file in outside folder. it showing as follows.


copy the font name which is placed in fonts/fontsfamily1469773845547.xml


place this font name at defaultPDFFont of above groovy code

run project take pdf.

Thank You

No comments:

Post a Comment