Class JRRtfExporter
- java.lang.Object
-
- net.sf.jasperreports.engine.JRAbstractExporter<RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput,JRRtfExporterContext>
-
- net.sf.jasperreports.engine.export.JRRtfExporter
-
- All Implemented Interfaces:
JRExporter<ExporterInput,RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput>,Exporter<ExporterInput,RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput>
public class JRRtfExporter extends JRAbstractExporter<RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput,JRRtfExporterContext>
Exports a JasperReports document to RTF format. TheJRRtfExporterimplementation helps to export JasperPrint documents in RTF format using RTF Specification 1.6. This means that the RTF files produced by this exporter are compatible with Microsoft Word 6.0, 2003 and XP. However, users might experience some problems when opening those RTF files with OpenOffice or StarOffice, as these products are not perfectly compatible with the RTF specifications from Microsoft. RTF is a character-based file format that supports absolute positioning of elements, which means that this exporter produces output very similar to that of theGraphics2Dand PDF exporters. TheRtfReportConfigurationprovides special configuration settings for this exporter. Almost all the provided samples show how to export to RTF.- Author:
- Flavius Sana (flavius_sana@users.sourceforge.net)
- See Also:
RtfReportConfiguration
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classJRRtfExporter.ExporterContext-
Nested classes/interfaces inherited from class net.sf.jasperreports.engine.JRAbstractExporter
JRAbstractExporter.BaseExporterContext, JRAbstractExporter.PageRange
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.awt.Color>colorsprotected FileBufferedWritercolorWriterprotected FileBufferedWritercontentWriterprotected java.io.FiledestFilestatic java.lang.StringEXCEPTION_MESSAGE_KEY_INVALID_TEXT_HEIGHTprotected java.util.List<java.lang.String>fontsprotected FileBufferedWriterfontWriterprotected static java.lang.StringJR_PAGE_ANCHOR_PREFIXprotected RenderersCacherenderersCacheprotected intreportIndexstatic java.lang.StringRTF_EXPORTER_KEYThe exporter key, as used inGenericElementHandlerEnviroment.getElementHandler(JRGenericElementType, String).static java.lang.StringRTF_EXPORTER_PROPERTIES_PREFIX-
Fields inherited from class net.sf.jasperreports.engine.JRAbstractExporter
allSelector, crtCompositeConfiguration, crtCompositeItemConfiguration, crtItem, dateFormatCache, EXCEPTION_MESSAGE_KEY_END_PAGE_INDEX_OUT_OF_RANGE, EXCEPTION_MESSAGE_KEY_INVALID_IMAGE_NAME, EXCEPTION_MESSAGE_KEY_INVALID_ZOOM_RATIO, EXCEPTION_MESSAGE_KEY_MIXED_CALLS_NOT_ALLOWED, EXCEPTION_MESSAGE_KEY_OUTPUT_WRITER_ERROR, EXCEPTION_MESSAGE_KEY_PAGE_INDEX_OUT_OF_RANGE, EXCEPTION_MESSAGE_KEY_START_PAGE_INDEX_OUT_OF_RANGE, exporterConfiguration, exporterContext, exporterInput, exporterOutput, filter, fontUtil, hyperlinkProducerFactory, itemConfiguration, jasperPrint, jasperReportsContext, noBackcolorSelector, noneSelector, numberFormatCache, parameters, propertiesUtil, PROPERTY_DEFAULT_FILTER_FACTORY, PROPERTY_SUFFIX_DEFAULT_FILTER_FACTORY, rendererUtil, styledTextUtil, textValueClasses
-
-
Constructor Summary
Constructors Constructor Description JRRtfExporter()JRRtfExporter(JasperReportsContext jasperReportsContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidendHyperlink(boolean startedHyperlink)protected voidensureOutput()protected voidexportElements(java.util.Collection<JRPrintElement> elements)protected voidexportEllipse(JRPrintEllipse ellipse)Draw a ellipse objectvoidexportFrame(JRPrintFrame frame)protected voidexportGenericElement(JRGenericPrintElement element)protected booleanexportHyperlink(JRPrintHyperlink link)voidexportImage(JRPrintImage printImage)Export a image objectprotected voidexportLine(JRPrintLine line)Draw a line objectprotected voidexportPage(JRPrintPage page, boolean lastPage)Exports a report pageprotected voidexportRectangle(JRPrintRectangle rectangle)Draw a rectanglevoidexportReport()Performs the export.protected voidexportReportToWriter(java.io.Writer writer)Export report in .rtf format to a streamprotected voidexportStyledTextRun(java.util.Map<java.text.AttributedCharacterIterator.Attribute,java.lang.Object> styledTextAttributes, java.lang.String text, java.util.Locale locale, java.awt.Color backcolor)voidexportText(JRPrintText text)Draw a text boxprotected java.lang.Class<RtfExporterConfiguration>getConfigurationInterface()java.lang.StringgetExporterKey()java.lang.StringgetExporterPropertiesPrefix()Returns the properties prefix for the current exporter.protected java.lang.Class<RtfReportConfiguration>getItemConfigurationInterface()protected voidinitExport()protected voidinitReport()protected voidwriteAnchor(java.lang.String anchorName)protected voidwriteShapeHyperlink(JRPrintHyperlink link)-
Methods inherited from class net.sf.jasperreports.engine.JRAbstractExporter
checkInterrupted, createFilter, defaultParseNumber, ensureInput, ensureJasperReportsContext, getBooleanCellValue, getCurrentConfiguration, getCurrentItemConfiguration, getCurrentJasperPrint, getDateCellValue, getDateFormat, getExporterContext, getExporterInput, getExporterOutput, getHyperlinkProducer, getJasperReportsContext, getLocale, getNumberCellValue, getNumberFormat, getOffsetX, getOffsetY, getPageRange, getParameter, getParameters, getPropertiesUtil, getRendererUtil, getReportContext, getRepository, getStyledText, getStyledText, getTextFormatFactoryClass, getTextLocale, getTextTimeZone, getTextValue, getTextValueString, insideFrame, reset, resetClassLoader, resetExportContext, restoreElementOffsets, setClassLoader, setConfiguration, setConfiguration, setCurrentExporterInputItem, setExporterInput, setExporterOutput, setFrameElementsOffset, setJasperReportsContext, setOffset, setOffset, setParameter, setParameters, setReportContext
-
-
-
-
Field Detail
-
RTF_EXPORTER_PROPERTIES_PREFIX
public static final java.lang.String RTF_EXPORTER_PROPERTIES_PREFIX
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_INVALID_TEXT_HEIGHT
public static final java.lang.String EXCEPTION_MESSAGE_KEY_INVALID_TEXT_HEIGHT
- See Also:
- Constant Field Values
-
RTF_EXPORTER_KEY
public static final java.lang.String RTF_EXPORTER_KEY
The exporter key, as used inGenericElementHandlerEnviroment.getElementHandler(JRGenericElementType, String).- See Also:
- Constant Field Values
-
JR_PAGE_ANCHOR_PREFIX
protected static final java.lang.String JR_PAGE_ANCHOR_PREFIX
- See Also:
- Constant Field Values
-
colorWriter
protected FileBufferedWriter colorWriter
-
fontWriter
protected FileBufferedWriter fontWriter
-
contentWriter
protected FileBufferedWriter contentWriter
-
destFile
protected java.io.File destFile
-
reportIndex
protected int reportIndex
-
colors
protected java.util.List<java.awt.Color> colors
-
fonts
protected java.util.List<java.lang.String> fonts
-
renderersCache
protected RenderersCache renderersCache
-
-
Constructor Detail
-
JRRtfExporter
public JRRtfExporter()
- See Also:
JRRtfExporter(JasperReportsContext)
-
JRRtfExporter
public JRRtfExporter(JasperReportsContext jasperReportsContext)
-
-
Method Detail
-
getConfigurationInterface
protected java.lang.Class<RtfExporterConfiguration> getConfigurationInterface()
-
getItemConfigurationInterface
protected java.lang.Class<RtfReportConfiguration> getItemConfigurationInterface()
-
ensureOutput
protected void ensureOutput()
- Specified by:
ensureOutputin classJRAbstractExporter<RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput,JRRtfExporterContext>
-
exportReport
public void exportReport() throws JRExceptionDescription copied from interface:ExporterPerforms the export.- Specified by:
exportReportin interfaceExporter<ExporterInput,RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput>- Specified by:
exportReportin classJRAbstractExporter<RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput,JRRtfExporterContext>- Throws:
JRException
-
initExport
protected void initExport()
- Overrides:
initExportin classJRAbstractExporter<RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput,JRRtfExporterContext>
-
initReport
protected void initReport()
- Overrides:
initReportin classJRAbstractExporter<RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput,JRRtfExporterContext>
-
exportReportToWriter
protected void exportReportToWriter(java.io.Writer writer) throws JRException, java.io.IOExceptionExport report in .rtf format to a stream- Throws:
JRExceptionjava.io.IOException
-
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:
JRExceptionjava.io.IOException
-
exportLine
protected void exportLine(JRPrintLine line) throws java.io.IOException
Draw a line object- Parameters:
line- JasperReports line object - JRPrintLine- Throws:
java.io.IOException
-
exportRectangle
protected void exportRectangle(JRPrintRectangle rectangle) throws java.io.IOException
Draw a rectangle- Parameters:
rectangle- JasperReports rectangle object (JRPrintRectangle)- Throws:
java.io.IOException
-
exportEllipse
protected void exportEllipse(JRPrintEllipse ellipse) throws java.io.IOException
Draw a ellipse object- Parameters:
ellipse- JasperReports ellipse object (JRPrintElipse)- Throws:
java.io.IOException
-
exportText
public void exportText(JRPrintText text) throws java.io.IOException, JRException
Draw a text box- Parameters:
text- JasperReports text object (JRPrintText)- Throws:
JRExceptionjava.io.IOException
-
exportStyledTextRun
protected void exportStyledTextRun(java.util.Map<java.text.AttributedCharacterIterator.Attribute,java.lang.Object> styledTextAttributes, java.lang.String text, java.util.Locale locale, java.awt.Color backcolor) throws java.io.IOException, JRException- Throws:
java.io.IOExceptionJRException
-
exportImage
public void exportImage(JRPrintImage printImage) throws JRException, java.io.IOException
Export a image object- Parameters:
printImage- JasperReports image object (JRPrintImage)- Throws:
JRExceptionjava.io.IOException
-
exportFrame
public void exportFrame(JRPrintFrame frame) throws JRException, java.io.IOException
- Parameters:
frame-- Throws:
JRExceptionjava.io.IOException
-
exportElements
protected void exportElements(java.util.Collection<JRPrintElement> elements) throws JRException, java.io.IOException
- Throws:
JRExceptionjava.io.IOException
-
exportGenericElement
protected void exportGenericElement(JRGenericPrintElement element)
-
exportHyperlink
protected boolean exportHyperlink(JRPrintHyperlink link) throws java.io.IOException
- Throws:
java.io.IOException
-
writeShapeHyperlink
protected void writeShapeHyperlink(JRPrintHyperlink link) throws java.io.IOException
- Throws:
java.io.IOException
-
endHyperlink
protected void endHyperlink(boolean startedHyperlink) throws java.io.IOException- Throws:
java.io.IOException
-
writeAnchor
protected void writeAnchor(java.lang.String anchorName) throws java.io.IOException- Throws:
java.io.IOException
-
getExporterKey
public java.lang.String getExporterKey()
- Specified by:
getExporterKeyin classJRAbstractExporter<RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput,JRRtfExporterContext>
-
getExporterPropertiesPrefix
public java.lang.String getExporterPropertiesPrefix()
Description copied from class:JRAbstractExporterReturns the properties prefix for the current exporter.- Specified by:
getExporterPropertiesPrefixin classJRAbstractExporter<RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput,JRRtfExporterContext>- Returns:
- the properties prefix for the current exporter
-
-