Class JRRtfExporter
- java.lang.Object
-
- net.sf.jasperreports.engine.JRAbstractExporter<RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput,JRRtfExporterContext>
-
- net.sf.jasperreports.engine.export.JRRtfExporter
-
- All Implemented Interfaces:
Exporter<ExporterInput,RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput>
public class JRRtfExporter extends JRAbstractExporter<RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput,JRRtfExporterContext>
Exports a JasperReports document to RTF format. TheJRRtfExporter
implementation 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 theGraphics2D
and PDF exporters. TheRtfReportConfiguration
provides 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 class
JRRtfExporter.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 List<Color>
colors
protected FileBufferedWriter
colorWriter
protected FileBufferedWriter
contentWriter
protected File
destFile
static String
EXCEPTION_MESSAGE_KEY_INVALID_TEXT_HEIGHT
protected List<String>
fonts
protected FileBufferedWriter
fontWriter
protected static String
JR_PAGE_ANCHOR_PREFIX
protected RenderersCache
renderersCache
protected int
reportIndex
static String
RTF_EXPORTER_KEY
The exporter key, as used inGenericElementHandlerEnviroment.getElementHandler(JRGenericElementType, String)
.static String
RTF_EXPORTER_PROPERTIES_PREFIX
-
Fields inherited from class net.sf.jasperreports.engine.JRAbstractExporter
allSelector, crtCompositeConfiguration, crtCompositeItemConfiguration, crtItem, dateFormatCache, EXCEPTION_MESSAGE_KEY_EMPTY_INPUT_SOURCE_IN_BATCH_MODE, EXCEPTION_MESSAGE_KEY_END_PAGE_INDEX_OUT_OF_RANGE, EXCEPTION_MESSAGE_KEY_INVALID_IMAGE_NAME, EXCEPTION_MESSAGE_KEY_INVALID_ZOOM_RATIO, EXCEPTION_MESSAGE_KEY_NO_INPUT_SOURCE, EXCEPTION_MESSAGE_KEY_NO_OUTPUT_SPECIFIED, 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, 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 void
endHyperlink(boolean startedHyperlink)
protected void
exportElements(Collection<JRPrintElement> elements)
protected void
exportEllipse(JRPrintEllipse ellipse)
Draw a ellipse objectvoid
exportFrame(JRPrintFrame frame)
protected void
exportGenericElement(JRGenericPrintElement element)
protected boolean
exportHyperlink(JRPrintHyperlink link)
void
exportImage(JRPrintImage printImage)
Export a image objectprotected void
exportLine(JRPrintLine line)
Draw a line objectprotected void
exportPage(JRPrintPage page, boolean lastPage)
Exports a report pageprotected void
exportRectangle(JRPrintRectangle rectangle)
Draw a rectanglevoid
exportReport()
Performs the export.protected void
exportReportToWriter(Writer writer)
Export report in .rtf format to a streamprotected void
exportStyledTextRun(Map<AttributedCharacterIterator.Attribute,Object> styledTextAttributes, String text, Locale locale, Color backcolor)
void
exportText(JRPrintText text)
Draw a text boxprotected Class<RtfExporterConfiguration>
getConfigurationInterface()
String
getExporterKey()
String
getExporterPropertiesPrefix()
Returns the properties prefix for the current exporter.protected Class<RtfReportConfiguration>
getItemConfigurationInterface()
protected void
initExport()
protected void
initReport()
protected void
writeAnchor(String anchorName)
protected void
writeShapeHyperlink(JRPrintHyperlink link)
-
Methods inherited from class net.sf.jasperreports.engine.JRAbstractExporter
checkInterrupted, createFilter, defaultParseNumber, ensureInput, ensureJasperReportsContext, ensureOutput, getBooleanCellValue, getCurrentConfiguration, getCurrentItemConfiguration, getCurrentJasperPrint, getDateCellValue, getDateFormat, getExporterConfiguration, getExporterContext, getExporterInput, getExporterOutput, getHyperlinkProducer, getJasperReportsContext, getLocale, getNumberCellValue, getNumberFormat, getOffsetX, getOffsetY, getPageRange, getPropertiesUtil, getRendererUtil, getReportContext, getReportExportConfiguration, getRepository, getStyledText, getStyledText, getTextFormatFactoryClass, getTextLocale, getTextTimeZone, getTextValue, getTextValueString, insideFrame, reset, resetExportContext, restoreElementOffsets, setConfiguration, setConfiguration, setCurrentExporterInputItem, setExporterInput, setExporterOutput, setFrameElementsOffset, setJasperReportsContext, setOffset, setOffset, setReportContext
-
-
-
-
Field Detail
-
RTF_EXPORTER_PROPERTIES_PREFIX
public static final String RTF_EXPORTER_PROPERTIES_PREFIX
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_INVALID_TEXT_HEIGHT
public static final String EXCEPTION_MESSAGE_KEY_INVALID_TEXT_HEIGHT
- See Also:
- Constant Field Values
-
RTF_EXPORTER_KEY
public static final 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 String JR_PAGE_ANCHOR_PREFIX
- See Also:
- Constant Field Values
-
colorWriter
protected FileBufferedWriter colorWriter
-
fontWriter
protected FileBufferedWriter fontWriter
-
contentWriter
protected FileBufferedWriter contentWriter
-
destFile
protected File destFile
-
reportIndex
protected int reportIndex
-
renderersCache
protected RenderersCache renderersCache
-
-
Constructor Detail
-
JRRtfExporter
public JRRtfExporter()
- See Also:
JRRtfExporter(JasperReportsContext)
-
JRRtfExporter
public JRRtfExporter(JasperReportsContext jasperReportsContext)
-
-
Method Detail
-
getConfigurationInterface
protected Class<RtfExporterConfiguration> getConfigurationInterface()
-
getItemConfigurationInterface
protected Class<RtfReportConfiguration> getItemConfigurationInterface()
-
exportReport
public void exportReport() throws JRException
Description copied from interface:Exporter
Performs the export.- Specified by:
exportReport
in interfaceExporter<ExporterInput,RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput>
- Specified by:
exportReport
in classJRAbstractExporter<RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput,JRRtfExporterContext>
- Throws:
JRException
-
initExport
protected void initExport()
- Overrides:
initExport
in classJRAbstractExporter<RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput,JRRtfExporterContext>
-
initReport
protected void initReport()
- Overrides:
initReport
in classJRAbstractExporter<RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput,JRRtfExporterContext>
-
exportReportToWriter
protected void exportReportToWriter(Writer writer) throws JRException, IOException
Export report in .rtf format to a stream- Throws:
JRException
IOException
-
exportPage
protected void exportPage(JRPrintPage page, boolean lastPage) throws JRException, IOException
Exports a report page- Parameters:
page
- Page that will be exported- Throws:
JRException
IOException
-
exportLine
protected void exportLine(JRPrintLine line) throws IOException
Draw a line object- Parameters:
line
- JasperReports line object - JRPrintLine- Throws:
IOException
-
exportRectangle
protected void exportRectangle(JRPrintRectangle rectangle) throws IOException
Draw a rectangle- Parameters:
rectangle
- JasperReports rectangle object (JRPrintRectangle)- Throws:
IOException
-
exportEllipse
protected void exportEllipse(JRPrintEllipse ellipse) throws IOException
Draw a ellipse object- Parameters:
ellipse
- JasperReports ellipse object (JRPrintElipse)- Throws:
IOException
-
exportText
public void exportText(JRPrintText text) throws IOException, JRException
Draw a text box- Parameters:
text
- JasperReports text object (JRPrintText)- Throws:
JRException
IOException
-
exportStyledTextRun
protected void exportStyledTextRun(Map<AttributedCharacterIterator.Attribute,Object> styledTextAttributes, String text, Locale locale, Color backcolor) throws IOException, JRException
- Throws:
IOException
JRException
-
exportImage
public void exportImage(JRPrintImage printImage) throws JRException, IOException
Export a image object- Parameters:
printImage
- JasperReports image object (JRPrintImage)- Throws:
JRException
IOException
-
exportFrame
public void exportFrame(JRPrintFrame frame) throws JRException, IOException
- Parameters:
frame
-- Throws:
JRException
IOException
-
exportElements
protected void exportElements(Collection<JRPrintElement> elements) throws JRException, IOException
- Throws:
JRException
IOException
-
exportGenericElement
protected void exportGenericElement(JRGenericPrintElement element)
-
exportHyperlink
protected boolean exportHyperlink(JRPrintHyperlink link) throws IOException
- Throws:
IOException
-
writeShapeHyperlink
protected void writeShapeHyperlink(JRPrintHyperlink link) throws IOException
- Throws:
IOException
-
endHyperlink
protected void endHyperlink(boolean startedHyperlink) throws IOException
- Throws:
IOException
-
writeAnchor
protected void writeAnchor(String anchorName) throws IOException
- Throws:
IOException
-
getExporterKey
public String getExporterKey()
- Specified by:
getExporterKey
in classJRAbstractExporter<RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput,JRRtfExporterContext>
-
getExporterPropertiesPrefix
public String getExporterPropertiesPrefix()
Description copied from class:JRAbstractExporter
Returns the properties prefix for the current exporter.- Specified by:
getExporterPropertiesPrefix
in classJRAbstractExporter<RtfReportConfiguration,RtfExporterConfiguration,WriterExporterOutput,JRRtfExporterContext>
- Returns:
- the properties prefix for the current exporter
-
-