net.sf.jasperreports.engine.export
Class JRRtfExporter

java.lang.Object
  extended bynet.sf.jasperreports.engine.JRAbstractExporter
      extended bynet.sf.jasperreports.engine.export.JRRtfExporter
All Implemented Interfaces:
JRExporter

public class JRRtfExporter
extends JRAbstractExporter

Exports a JasperReports document to RTF format. It has binary output type and exports the document to a free-form layout. It uses the RTF Specification 1.6 (compatible with MS Word 6.0, 2003 and XP).

Since classic AWT fonts can be sometimes very different from system fonts (which are used by RTF viewers), a font mapping feature was added. By using the JRExporterParameter.FONT_MAP parameter, a logical font like "sansserif" can be mapped to a system specific font, like "Comic Sans MS". Both map keys and values are strings.

Version:
$Id: JRRtfExporter.java,v 1.43 2005/11/28 09:20:44 teodord Exp $
Author:
Flavius Sana (flavius_sana@users.sourceforge.net)

Field Summary
protected  java.util.List colors
           
protected  java.io.File destFile
           
protected  java.util.List fonts
           
protected  JRExportProgressMonitor progressMonitor
           
protected  int reportIndex
           
protected  java.io.Writer writer
           
 
Fields inherited from class net.sf.jasperreports.engine.JRAbstractExporter
classLoader, defaultFont, endPageIndex, globalOffsetX, globalOffsetY, isModeBatch, jasperPrint, jasperPrintList, parameters, startPageIndex, styledTextParser
 
Constructor Summary
JRRtfExporter()
           
 
Method Summary
protected  void createColorAndFontEntries()
          Create color and font entries for the header of .rtf file.
protected  void exportElements(java.util.Collection elements, int offsetx, int offsety)
           
protected  void exportEllipse(JRPrintEllipse ellipse, int offsetx, int offsety)
          Draw a ellipse object
protected  void exportFrame(JRPrintFrame frame, int offsetx, int offsety)
           
protected  void exportImage(JRPrintImage printImage, int offsetx, int offsety)
          Export a image object
protected  void exportLine(JRPrintLine line, int offsetx, int offsety)
          Draw a line object
protected  void exportPage(JRPrintPage page, boolean lastPage)
          Exports a report page
protected  void exportRectangle(JRPrintRectangle rect, int offsetx, int offsety)
          Draw a rectangle
 void exportReport()
          Export report in .rtf format
protected  java.lang.StringBuffer exportReportToBuffer()
          Export report in .rtf format
protected  void exportReportToFile()
          Export report to a file in the .rtf format
protected  void exportReportToStream()
          Export report in .rtf format to a stream
protected  void exportText(JRPrintText text, int offsetx, int offsety)
          Draw a text box
protected  int getAdjustment(byte pen)
          Get border adjustment for graphic elements depending on pen width used
 
Methods inherited from class net.sf.jasperreports.engine.JRAbstractExporter
getBox, getDefaultFont, getOffsetX, getOffsetY, getParameter, getParameters, getStyledText, getStyledText, resetClassLoader, restoreElementOffsets, setClassLoader, setFrameElementsOffset, setInput, setOffset, setOutput, setPageRange, setParameter, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

progressMonitor

protected JRExportProgressMonitor progressMonitor

writer

protected java.io.Writer writer

destFile

protected java.io.File destFile

reportIndex

protected int reportIndex

colors

protected java.util.List colors

fonts

protected java.util.List fonts
Constructor Detail

JRRtfExporter

public JRRtfExporter()
Method Detail

exportReport

public void exportReport()
                  throws JRException
Export report in .rtf format

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

exportReportToBuffer

protected java.lang.StringBuffer exportReportToBuffer()
                                               throws JRException
Export report in .rtf format

Returns:
report in .rtf format in a StringBuffer object
Throws:
JRException

exportReportToStream

protected void exportReportToStream()
                             throws JRException,
                                    java.io.IOException
Export report in .rtf format to a stream

Throws:
JRException
java.io.IOException

exportReportToFile

protected void exportReportToFile()
                           throws JRException
Export report to a file in the .rtf format

Throws:
JRException

createColorAndFontEntries

protected void createColorAndFontEntries()
                                  throws JRException
Create color and font entries for the header of .rtf file. Each color is represented by values of the red, green and blue components.

Throws:
JRException

exportPage

protected void exportPage(JRPrintPage page,
                          boolean lastPage)
                   throws JRException,
                          java.io.IOException
Exports a report page

Parameters:
page - Page that will be exported
Throws:
JRException
java.io.IOException

getAdjustment

protected int getAdjustment(byte pen)
Get border adjustment for graphic elements depending on pen width used

Parameters:
pen -

exportLine

protected void exportLine(JRPrintLine line,
                          int offsetx,
                          int offsety)
                   throws java.io.IOException
Draw a line object

Parameters:
line - JasperReports line object - JRPrintLine
offsetx - If the object is in a frame this parameter represents the x offset of the element
offsety - If the object is in a frame this parameter represents the y offset of the element
Throws:
java.io.IOException

exportRectangle

protected void exportRectangle(JRPrintRectangle rect,
                               int offsetx,
                               int offsety)
                        throws java.io.IOException
Draw a rectangle

Parameters:
rect - JasperReports rectangle object (JRPrintRectangle)
offsetx - If the object is in a frame this parameter represents the x offset of the element
offsety - If the object is in a frame this parameter represents the y offset of the element
Throws:
java.io.IOException

exportEllipse

protected void exportEllipse(JRPrintEllipse ellipse,
                             int offsetx,
                             int offsety)
                      throws java.io.IOException
Draw a ellipse object

Parameters:
ellipse - JasperReports ellipse object (JRPrintElipse)
offsetx - If the object is in a frame this parameter represents the x offset of the element
offsety - If the object is in a frame this parameter represents the y offset of the element
Throws:
java.io.IOException

exportText

protected void exportText(JRPrintText text,
                          int offsetx,
                          int offsety)
                   throws java.io.IOException,
                          JRException
Draw a text box

Parameters:
text - JasperReports text object (JRPrintText)
offsetx - If the object is in a frame this parameter represents the x offset of the element
offsety - If the object is in a frame this parameter represents the y offset of the element
Throws:
JRException
java.io.IOException

exportImage

protected void exportImage(JRPrintImage printImage,
                           int offsetx,
                           int offsety)
                    throws JRException,
                           java.io.IOException
Export a image object

Parameters:
printImage - JasperReports image object (JRPrintImage)
offsetx - If the object is in a frame this parameter represents the x offset of the element
offsety - If the object is in a frame this parameter represents the y offset of the element
Throws:
JRException
java.io.IOException

exportFrame

protected void exportFrame(JRPrintFrame frame,
                           int offsetx,
                           int offsety)
                    throws JRException,
                           java.io.IOException
Parameters:
frame -
Throws:
JRException
java.io.IOException

exportElements

protected void exportElements(java.util.Collection elements,
                              int offsetx,
                              int offsety)
                       throws JRException,
                              java.io.IOException
Throws:
JRException
java.io.IOException


© 2001-2005 JasperSoft Corporation www.jaspersoft.com