net.sf.jasperreports.engine.export
Class JRTextExporter

java.lang.Object
  extended by net.sf.jasperreports.engine.JRAbstractExporter
      extended by net.sf.jasperreports.engine.export.JRTextExporter
All Implemented Interfaces:
JRExporter

public class JRTextExporter
extends JRAbstractExporter

Exports filled reports in plain text format. The text exporter allows users to define a custom character resolution (the number of columns and rows in text format). Since the character resolution is mapped on the actual pixel resolution, every character corresponds to a rectangle of pixels. If a certain text element has a smaller size in pixels (width, height, or both) than the number of pixels that map to a character, the text element will not be rendered. Because of this, users must take some precautions when creating reports for text export. First, they must make sure the page size in characters is large enough to render the report, because if the report pages contain too much text, some of it may be rendered only partially. On the other hand, if the character resolution is too small compared to the pixel resolution (say, a height of 20 characters for a page 800 pixels tall) all texts with sizes smaller than the one needed to map to a character, will not be displayed (in the previous example, a text element needs to be at least 800/20 = 40 pixels tall in order to be rendered).

As a conclusion, the text exporter will yield the better results if the space needed for displaying a text is large. So users have to either design reports with few text or export to big text pages. Another good practice is to arrange text elements at design time as similar as possible to a grid.

Version:
$Id: JRTextExporter.java 5180 2012-03-29 13:23:12Z teodord $
Author:
Ionut Nedelcu (ionutned@users.sourceforge.net)
See Also:
JRExporterParameter

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.jasperreports.engine.JRAbstractExporter
JRAbstractExporter.BaseExporterContext, JRAbstractExporter.ParameterOverriddenResolver, JRAbstractExporter.ParameterOverrideResolver, JRAbstractExporter.ParameterResolver
 
Field Summary
protected  java.lang.String betweenPagesText
           
protected  float charHeight
           
protected  float charWidth
           
protected  java.lang.String lineSeparator
           
protected  int pageHeightInChars
           
protected  int pageWidthInChars
           
protected  JRExportProgressMonitor progressMonitor
           
protected static java.lang.String systemLineSeparator
           
protected  java.io.Writer writer
           
 
Fields inherited from class net.sf.jasperreports.engine.JRAbstractExporter
dateFormatCache, endPageIndex, filter, fontMap, globalOffsetX, globalOffsetY, hyperlinkProducerFactory, isModeBatch, jasperPrint, jasperPrintList, jasperReportsContext, numberFormatCache, parameters, PROPERTY_DEFAULT_FILTER_FACTORY, PROPERTY_SUFFIX_DEFAULT_FILTER_FACTORY, startPageIndex
 
Constructor Summary
JRTextExporter()
           
JRTextExporter(JasperReportsContext jasperReportsContext)
           
 
Method Summary
protected  void exportElements(java.util.List<JRPrintElement> elements)
           
protected  void exportPage(JRPrintPage page)
          Exports a page to the output writer.
 void exportReport()
          Actually starts the export process.
protected  void exportReportToWriter()
           
protected  void exportText(JRPrintText element)
          Renders a text and places it in the output matrix.
protected  java.lang.String getExporterKey()
           
protected  int getHeightInChars(int height)
          Transforms height from pixel space to character space.
protected  JRStyledText getStyledText(JRPrintText textElement)
           
protected  int getWidthInChars(int width)
          Transforms width from pixel space to character space.
 void setReportParameters()
           
 
Methods inherited from class net.sf.jasperreports.engine.JRAbstractExporter
createFilter, defaultParseNumber, getBooleanCellValue, getBooleanParameter, getCharacterParameter, getCustomHandler, getDateCellValue, getDateFormat, getFloatParameter, getHyperlinkProducer, getIntegerParameter, getJasperReportsContext, getLocale, getNumberCellValue, getNumberFormat, getOffsetX, getOffsetY, getParameter, getParameterResolver, getParameters, getPropertiesUtil, getReportContext, getStringArrayParameter, getStringParameter, getStringParameterOrDefault, getStyledText, getTextFormatFactoryClass, getTextLocale, getTextTimeZone, getTextValue, getTextValueString, reset, resetClassLoader, resetExportContext, restoreElementOffsets, setClassLoader, setExportContext, setFontMap, setFrameElementsOffset, setHyperlinkProducerFactory, setInput, setJasperPrint, setOffset, setOffset, setOutput, setPageRange, setParameter, setParameters, setReportContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pageWidthInChars

protected int pageWidthInChars

pageHeightInChars

protected int pageHeightInChars

charWidth

protected float charWidth

charHeight

protected float charHeight

progressMonitor

protected JRExportProgressMonitor progressMonitor

writer

protected java.io.Writer writer

betweenPagesText

protected java.lang.String betweenPagesText

lineSeparator

protected java.lang.String lineSeparator

systemLineSeparator

protected static final java.lang.String systemLineSeparator
Constructor Detail

JRTextExporter

public JRTextExporter()
See Also:
JRTextExporter(JasperReportsContext)

JRTextExporter

public JRTextExporter(JasperReportsContext jasperReportsContext)
Method Detail

exportReport

public void exportReport()
                  throws JRException
Description copied from interface: JRExporter
Actually starts the export process.

Specified by:
exportReport in interface JRExporter
Specified by:
exportReport in class JRAbstractExporter
Throws:
JRException

setReportParameters

public void setReportParameters()
                         throws JRException
Throws:
JRException

exportReportToWriter

protected void exportReportToWriter()
                             throws JRException,
                                    java.io.IOException
Throws:
JRException
java.io.IOException

exportPage

protected void exportPage(JRPrintPage page)
                   throws java.io.IOException
Exports a page to the output writer. Only text elements within the page are considered. For each page, the engine creates a matrix of characters and each rendered text element is placed at the appropiate position in the matrix. After all texts are parsed, the character matrix is sent to the output writer.

Throws:
java.io.IOException

exportElements

protected void exportElements(java.util.List<JRPrintElement> elements)

exportText

protected void exportText(JRPrintText element)
Renders a text and places it in the output matrix.


getHeightInChars

protected int getHeightInChars(int height)
Transforms height from pixel space to character space.


getWidthInChars

protected int getWidthInChars(int width)
Transforms width from pixel space to character space.


getStyledText

protected JRStyledText getStyledText(JRPrintText textElement)
Overrides:
getStyledText in class JRAbstractExporter

getExporterKey

protected java.lang.String getExporterKey()
Specified by:
getExporterKey in class JRAbstractExporter


© 2001-2010 Jaspersoft Corporation www.jaspersoft.com