Upload
hayri-ozler
View
246
Download
7
Tags:
Embed Size (px)
Citation preview
Teodor Danciu, Founder of JasperReports
JasperReports Tips & Tricks
1
Agenda
� Font Extensions
� Data-Centric Excel Output
©2011 Jaspersoft Corp. All rights reserved.
Don’t Forget to Package Your FontsDon’t Forget to Package Your Fonts
©2011 Jaspersoft Corporation. Proprietary and Confidential3
Font Related Issues
� Font metrics are important in report layout� Stretch-with-overflow text fields
� Fonts are not readily available on target platforms� Arial exists only on Windows
� Fonts are required resources in pixel-perfect reports� Think of a font just like you think of a logo on the report� Think of a font just like you think of a logo on the report
� Some document formats can embed fonts� PDF
� Fonts support a limited set of languages� Need different TTF files for CKJ languages
©2011 Jaspersoft Corp. All rights reserved.
Font Usage in JasperReports
� JasperReports uses AWT for rendering and layout calculation during report filling
� AWT uses java.awt.Font instances
� Java Logical Fonts: SansSerif, Serif, Monospaced, Dialog, DialogInput
� Physical Fonts (System): Arial, Comic Sans MS, Tahoma, etc
� Dynamically Loaded Fonts (TTF): Font.createFont()� Dynamically Loaded Fonts (TTF): Font.createFont()
� PDF uses com.itextpdf.text.Font instances
� 14 Built-in Fonts: Helvetica, Helvetica-Oblique, Helvetica-Bold, Times-
Roman, Time-Bold, Courier, etc
� Embedded Fonts
©2011 Jaspersoft Corp. All rights reserved.
Deprecated Font Usage Techniques
� Missing fonts silently ignored
� PDF font related attributes� pdfFontName, pdfEncoding, isPdfEmbedded
� FONT_MAP exporter parameter
©2011 Jaspersoft Corp. All rights reserved.
Font Extensions
� A way to package up fonts together with your reports
� Font extensions add to the list of available fonts
� Simplifies font usage
� Contains exporter related mappings
� Built-in internationalization support� Built-in internationalization support
©2011 Jaspersoft Corp. All rights reserved.
New Font Usage Techniques
� Only fontName, isBold and isItalic attributes
matter
� Missing font raises exception
©2011 Jaspersoft Corp. All rights reserved.
Font Extension Example
jasperreports_extension.properties
...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
©2011 Jaspersoft Corp. All rights reserved.
=net/sf/jasperreports/fonts/fonts.xml
...
Font Extension Example
<?xml version="1.0" encoding="UTF-8"?>
<fontFamilies>
<fontFamily name="DejaVu Sans">
...
</fontFamily>
<fontFamily name="DejaVu Serif">
©2011 Jaspersoft Corp. All rights reserved.
<fontFamily name="DejaVu Serif">
...
</fontFamily>
<fontFamily name="DejaVu Sans Mono">
...
</fontFamily>
...
</fontFamilies>
Font Extension Example
<fontFamily name="DejaVu Sans">
<normal>fonts/dejavu/DejaVuSans.ttf</normal>
<bold>fonts/dejavu/DejaVuSans-Bold.ttf</bold>
<italic>fonts/dejavu/DejaVuSans-Oblique.ttf</italic>
<boldItalic>fonts/dejavu/DejaVuSans-BoldOblique.ttf</boldItalic>
<pdfEncoding>Identity-H</pdfEncoding>
<pdfEmbedded>true</pdfEmbedded>
<exportFonts>
<export key="net.sf.jasperreports.html">'DejaVu Sans', Arial,
©2011 Jaspersoft Corp. All rights reserved.
<export key="net.sf.jasperreports.html">'DejaVu Sans', Arial,
Helvetica, sans-serif</export>
<export key="net.sf.jasperreports.xhtml">'DejaVu Sans', Arial,
Helvetica, sans-serif</export>
</exportFonts>
<!--
<locales>
<locale>en_US</locale>
<locale>de_DE</locale>
</locales>
-->
</fontFamily>
Demonstration
� iReport Font Extension Wizard� Install New Fonts
� Export Fonts in JAR
©2011 Jaspersoft Corp. All rights reserved.
Data-Centric Excel OutputData-Centric Excel Output
©2011 Jaspersoft Corporation. Proprietary and Confidential13
Free Form vs Grid-based Document
Formats
� Free Form / Absolute Positioned Exporters� AWT, PDF, RTF, PPTX, XHTML/CSS
� Grid-based Exporters� HTML, XLS, XLSX, DOCX, ODT, ODS
©2011 Jaspersoft Corp. All rights reserved.
a) Inefficient Layout b) Grid-friendly Layout
Excel Exporters Configuration
� Preserve Cell Value Type� net.sf.jasperreports.export.xls.detect.cell.type
� Ignore Graphics� net.sf.jasperreports.export.xls.ignore.graphics
� Ignore Cell Formatting� net.sf.jasperreports.export.xls.white.page.background
� net.sf.jasperreports.export.xls.ignore.cell.background
� net.sf.jasperreports.export.xls.ignore.cell.border
©2011 Jaspersoft Corp. All rights reserved.
Excel Exporters Configuration
� Ignore Pagination� net.sf.jasperreports.export.xls.one.page.per.sheet
� net.sf.jasperreports.export.{format}.exclude.origin.{suffix}.{arbitrary_na
me}
� net.sf.jasperreports.export.{format}.exclude.origin.keep.first.{suffix}.{ar
bitrary_name}
� Remove Empty Cell Used for Spacing� net.sf.jasperreports.export.xls.remove.empty.space.between.columns
� net.sf.jasperreports.export.xls.remove.empty.space.between.rows
� net.sf.jasperreports.export.xls.collapse.row.span
©2011 Jaspersoft Corp. All rights reserved.
Demonstration
� Data-centric Excel Output� Set configuration properties
� See the effects
©2011 Jaspersoft Corp. All rights reserved.
Conclusions
� Think of fonts as a required resource that go with your report templates
� Exporters are highly customizable/configurable features
©2011 Jaspersoft Corp. All rights reserved.
Resources
� More information about these and other features of JasperReports library can be found at:
http://www.jasperforge.org/jasperreports
©2011 Jaspersoft Corp. All rights reserved.
Questions
©2011 Jaspersoft Corp. All rights reserved.
Thank You and
Good Luck!