Class HtmlExporter
- java.lang.Object
-
- net.sf.jasperreports.engine.JRAbstractExporter<RC,C,HtmlExporterOutput,JRHtmlExporterContext>
-
- net.sf.jasperreports.engine.export.AbstractHtmlExporter<HtmlReportConfiguration,HtmlExporterConfiguration>
-
- net.sf.jasperreports.engine.export.HtmlExporter
-
- All Implemented Interfaces:
JRExporter<ExporterInput,HtmlReportConfiguration,HtmlExporterConfiguration,HtmlExporterOutput>
,Exporter<ExporterInput,HtmlReportConfiguration,HtmlExporterConfiguration,HtmlExporterOutput>
public class HtmlExporter extends AbstractHtmlExporter<HtmlReportConfiguration,HtmlExporterConfiguration>
- Author:
- Lucian Chirita (lucianc@users.sourceforge.net)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
HtmlExporter.CellElementVisitor
protected class
HtmlExporter.ExporterContext
protected class
HtmlExporter.HtmlStyledTextListWriter
protected class
HtmlExporter.TableVisitor
-
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.LinkedList<java.awt.Color>
backcolorStack
static java.lang.String
HTML_EXPORTER_KEY
The exporter key, as used inGenericElementHandlerEnviroment.getElementHandler(JRGenericElementType, String)
.static java.lang.String
HTML_EXPORTER_PROPERTIES_PREFIX
protected java.util.Map<Pair<java.lang.String,java.awt.Rectangle>,java.lang.String>
imageMaps
protected int
pageIndex
protected int
pointerEventsNoneStack
static java.lang.String
PROPERTY_HTML_CLASS
Property that provides the value for theclass
CSS style property to be applied to elements in the table generated for the report.static java.lang.String
PROPERTY_HTML_ID
protected RenderersCache
renderersCache
protected java.util.Map<java.lang.String,java.lang.String>
rendererToImagePathMap
protected int
reportIndex
protected ExporterFilter
tableFilter
protected JRHyperlinkTargetProducerFactory
targetProducerFactory
protected java.io.Writer
writer
-
Fields inherited from class net.sf.jasperreports.engine.export.AbstractHtmlExporter
CSS_TEXT_ALIGN_CENTER, CSS_TEXT_ALIGN_JUSTIFY, CSS_TEXT_ALIGN_LEFT, CSS_TEXT_ALIGN_RIGHT, DEFAULT_ZOOM, fontHandler, fontsToProcess, HTML_VERTICAL_ALIGN_BOTTOM, HTML_VERTICAL_ALIGN_MIDDLE, HTML_VERTICAL_ALIGN_TOP, IMAGE_NAME_PREFIX, IMAGE_NAME_PREFIX_LEGTH, imageHandler, JR_BOOKMARK_ANCHOR_PREFIX, JR_PAGE_ANCHOR_PREFIX, resourceHandler
-
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 HtmlExporter()
HtmlExporter(JasperReportsContext jasperReportsContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.awt.Color
appendBackcolorStyle(TableCell cell, java.lang.StringBuilder styleBuffer)
protected boolean
appendBorderStyle(JRLineBox box, java.lang.StringBuilder styleBuffer)
protected void
appendElementCellGenericStyle(TableCell cell, java.lang.StringBuilder styleBuffer)
protected boolean
appendPadding(java.lang.StringBuilder sb, java.lang.Integer padding, java.lang.String side)
protected boolean
appendPaddingStyle(JRLineBox box, java.lang.StringBuilder styleBuffer)
protected boolean
appendPen(java.lang.StringBuilder sb, JRPen pen, java.lang.String side)
protected void
appendSizeStyle(int width, int height, java.lang.StringBuilder styleBuffer)
protected void
endCell(TableCell.CellType cellType)
protected void
endHeading(AccessibilityTagEnum headingTag)
protected void
endHyperlink()
protected void
ensureOutput()
void
exportElements(java.util.List<JRPrintElement> elements)
protected void
exportPage(JRPrintPage page)
protected void
exportParagraph(StyledTextWriteContext context, JRPrintText printText, java.text.AttributedCharacterIterator allParagraphs, int paragraphStart, java.lang.String paragraphText, java.lang.Integer firstLineIndent, boolean justifyLastLine, java.lang.String tooltip, boolean hyperlinkStarted)
void
exportReport()
Performs the export.protected void
exportReportToWriter()
protected void
exportStyledText(JRPrintText printText, JRStyledText styledText, java.lang.String tooltip, boolean hyperlinkStarted)
protected void
exportStyledTextRun(java.lang.String textRunStyle, java.util.Map<java.text.AttributedCharacterIterator.Attribute,java.lang.Object> attributes, java.lang.String text, java.lang.String tooltip, boolean hyperlinkStarted)
protected void
exportTable(HtmlExporter.TableVisitor tableVisitor, Table table, boolean whiteBackground, boolean isMainReportTable)
protected void
finishStartCell()
protected java.lang.String
getCellProperty(JRPrintElement element, TableCell cell, java.lang.String key)
protected java.lang.Class<HtmlExporterConfiguration>
getConfigurationInterface()
java.lang.String
getDataAttributes(JRPrintElement element, TableCell cell)
protected JRPrintElementIndex
getElementIndex(TableCell cell)
java.lang.String
getExporterKey()
java.lang.String
getExporterPropertiesPrefix()
Returns the properties prefix for the current exporter.protected java.lang.String
getHyperlinkTarget(JRPrintHyperlink link)
protected java.lang.String
getHyperlinkURL(JRPrintHyperlink link)
protected java.lang.String
getImageHorizontalAlignmentStyle(JRPrintImage image)
protected java.lang.String
getImageVerticalAlignmentStyle(JRPrintImage image)
protected java.lang.Class<HtmlReportConfiguration>
getItemConfigurationInterface()
protected java.lang.String
getTextRunStyle(java.util.Map<java.text.AttributedCharacterIterator.Attribute,java.lang.Object> attributes, java.util.Locale locale, LineSpacingEnum lineSpacing, java.lang.Float lineSpacingSize, float lineSpacingFactor, java.awt.Color backcolor, boolean hyperlinkStarted)
protected void
initExport()
protected void
initReport()
protected boolean
isOblique(JRPrintLine line)
protected boolean
matchesBackcolor(java.awt.Color backcolor)
protected java.lang.String
resolveHyperlinkURL(int reportIndex, JRPrintHyperlink link)
protected void
restoreBackcolor()
protected void
setBackcolor(java.awt.Color color)
protected void
setJasperReportsContext(JasperReportsContext jasperReportsContext)
protected java.lang.String
setRotationStyles(JRPrintText text, java.lang.String horizontalAlignment, java.lang.StringBuilder spanStyleBuffer, java.lang.StringBuilder divStyleBuffer)
protected void
startCell(int colSpan, int rowSpan, TableCell.CellType cellType)
protected void
startCell(TableCell cell)
protected void
startCell(JRPrintElement element, TableCell cell)
protected AccessibilityTagEnum
startHeading(JRPrintText text)
protected boolean
startHyperlink(JRPrintHyperlink link)
java.lang.String
toSizeUnit(float size)
protected float
toZoom(float size)
protected void
writeEllipse(JRPrintEllipse ellipse, TableCell cell)
protected void
writeEmptyCell(int colSpan, int rowSpan)
protected void
writeFrameCell(TableCell cell)
protected void
writeGenericElement(JRGenericPrintElement element, TableCell cell)
void
writeImage(JRPrintImage image, TableCell cell)
protected void
writeImageAreaCoordinates(int[] coords)
protected void
writeImageAreaHyperlink(JRPrintHyperlink hyperlink)
protected void
writeImageMap(java.lang.String imageMapName, JRPrintImage image, java.util.List<JRPrintImageAreaHyperlink> imageMapAreas)
protected void
writeLayers(java.util.List<Table> layers, HtmlExporter.TableVisitor tableVisitor, TableCell cell)
protected void
writeLine(JRPrintLine line, TableCell cell)
protected void
writeNestedTable(Table table, HtmlExporter.TableVisitor tableVisitor, TableCell cell)
protected void
writeRectangle(JRPrintRectangle rectangle, TableCell cell)
protected void
writeStyle(java.lang.StringBuilder styleBuffer)
protected void
writeSvgStyle(JRPrintGraphicElement element)
protected void
writeText(JRPrintText text, TableCell cell)
-
Methods inherited from class net.sf.jasperreports.engine.export.AbstractHtmlExporter
addFontFamily, getFontFamily, getFontHandler, getImage, getImage, getImageHandler, getImageName, getImageName, getPrintElementIndex, getResourceHandler, getStyledText, handleFont, isConvertSvgToImage, isEmbeddedSvgUseFonts, isEmbedImage, isOverrideHints, isUseBackgroundImageToAlign, resolveFontFamily, setFontHandler, setImageHandler, setResourceHandler
-
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, getTextFormatFactoryClass, getTextLocale, getTextTimeZone, getTextValue, getTextValueString, insideFrame, reset, resetClassLoader, resetExportContext, restoreElementOffsets, setClassLoader, setConfiguration, setConfiguration, setCurrentExporterInputItem, setExporterInput, setExporterOutput, setFrameElementsOffset, setOffset, setOffset, setParameter, setParameters, setReportContext
-
-
-
-
Field Detail
-
HTML_EXPORTER_KEY
public static final java.lang.String HTML_EXPORTER_KEY
The exporter key, as used inGenericElementHandlerEnviroment.getElementHandler(JRGenericElementType, String)
.- See Also:
- Constant Field Values
-
HTML_EXPORTER_PROPERTIES_PREFIX
public static final java.lang.String HTML_EXPORTER_PROPERTIES_PREFIX
- See Also:
- Constant Field Values
-
PROPERTY_HTML_CLASS
public static final java.lang.String PROPERTY_HTML_CLASS
Property that provides the value for theclass
CSS style property to be applied to elements in the table generated for the report. The value of this property will be used as the value for theclass
attribute of the<td>
tag for the element when exported to HTML and/or theclass
attribute of the<span>
or<div>
tag for the element, when exported to XHTML/CSS.- See Also:
- Constant Field Values
-
PROPERTY_HTML_ID
public static final java.lang.String PROPERTY_HTML_ID
- See Also:
- Constant Field Values
-
targetProducerFactory
protected JRHyperlinkTargetProducerFactory targetProducerFactory
-
rendererToImagePathMap
protected java.util.Map<java.lang.String,java.lang.String> rendererToImagePathMap
-
imageMaps
protected java.util.Map<Pair<java.lang.String,java.awt.Rectangle>,java.lang.String> imageMaps
-
renderersCache
protected RenderersCache renderersCache
-
writer
protected java.io.Writer writer
-
reportIndex
protected int reportIndex
-
pageIndex
protected int pageIndex
-
backcolorStack
protected java.util.LinkedList<java.awt.Color> backcolorStack
-
tableFilter
protected ExporterFilter tableFilter
-
pointerEventsNoneStack
protected int pointerEventsNoneStack
-
-
Constructor Detail
-
HtmlExporter
public HtmlExporter()
-
HtmlExporter
public HtmlExporter(JasperReportsContext jasperReportsContext)
-
-
Method Detail
-
getExporterKey
public java.lang.String getExporterKey()
- Specified by:
getExporterKey
in classJRAbstractExporter<HtmlReportConfiguration,HtmlExporterConfiguration,HtmlExporterOutput,JRHtmlExporterContext>
-
getExporterPropertiesPrefix
public java.lang.String getExporterPropertiesPrefix()
Description copied from class:JRAbstractExporter
Returns the properties prefix for the current exporter.- Specified by:
getExporterPropertiesPrefix
in classJRAbstractExporter<HtmlReportConfiguration,HtmlExporterConfiguration,HtmlExporterOutput,JRHtmlExporterContext>
- Returns:
- the properties prefix for the current exporter
-
exportReport
public void exportReport() throws JRException
Description copied from interface:Exporter
Performs the export.- Specified by:
exportReport
in interfaceExporter<ExporterInput,HtmlReportConfiguration,HtmlExporterConfiguration,HtmlExporterOutput>
- Specified by:
exportReport
in classJRAbstractExporter<HtmlReportConfiguration,HtmlExporterConfiguration,HtmlExporterOutput,JRHtmlExporterContext>
- Throws:
JRException
-
getConfigurationInterface
protected java.lang.Class<HtmlExporterConfiguration> getConfigurationInterface()
-
getItemConfigurationInterface
protected java.lang.Class<HtmlReportConfiguration> getItemConfigurationInterface()
-
ensureOutput
protected void ensureOutput()
- Specified by:
ensureOutput
in classJRAbstractExporter<HtmlReportConfiguration,HtmlExporterConfiguration,HtmlExporterOutput,JRHtmlExporterContext>
-
initExport
protected void initExport()
- Overrides:
initExport
in classJRAbstractExporter<HtmlReportConfiguration,HtmlExporterConfiguration,HtmlExporterOutput,JRHtmlExporterContext>
-
initReport
protected void initReport()
- Overrides:
initReport
in classJRAbstractExporter<HtmlReportConfiguration,HtmlExporterConfiguration,HtmlExporterOutput,JRHtmlExporterContext>
-
setJasperReportsContext
protected void setJasperReportsContext(JasperReportsContext jasperReportsContext)
-
exportReportToWriter
protected void exportReportToWriter() throws JRException, java.io.IOException
- Throws:
JRException
java.io.IOException
-
exportPage
protected void exportPage(JRPrintPage page) throws java.io.IOException
- Throws:
java.io.IOException
-
exportElements
public void exportElements(java.util.List<JRPrintElement> elements) throws java.io.IOException
- Throws:
java.io.IOException
-
exportTable
protected void exportTable(HtmlExporter.TableVisitor tableVisitor, Table table, boolean whiteBackground, boolean isMainReportTable) throws java.io.IOException
- Throws:
java.io.IOException
-
writeText
protected void writeText(JRPrintText text, TableCell cell) throws java.io.IOException
- Throws:
java.io.IOException
-
setRotationStyles
protected java.lang.String setRotationStyles(JRPrintText text, java.lang.String horizontalAlignment, java.lang.StringBuilder spanStyleBuffer, java.lang.StringBuilder divStyleBuffer)
-
appendSizeStyle
protected void appendSizeStyle(int width, int height, java.lang.StringBuilder styleBuffer)
-
writeImage
public void writeImage(JRPrintImage image, TableCell cell) throws java.io.IOException, JRException
- Throws:
java.io.IOException
JRException
-
getImageHorizontalAlignmentStyle
protected java.lang.String getImageHorizontalAlignmentStyle(JRPrintImage image)
-
getImageVerticalAlignmentStyle
protected java.lang.String getImageVerticalAlignmentStyle(JRPrintImage image)
-
getElementIndex
protected JRPrintElementIndex getElementIndex(TableCell cell)
-
writeImageMap
protected void writeImageMap(java.lang.String imageMapName, JRPrintImage image, java.util.List<JRPrintImageAreaHyperlink> imageMapAreas) throws java.io.IOException
- Throws:
java.io.IOException
-
writeImageAreaCoordinates
protected void writeImageAreaCoordinates(int[] coords) throws java.io.IOException
- Throws:
java.io.IOException
-
writeImageAreaHyperlink
protected void writeImageAreaHyperlink(JRPrintHyperlink hyperlink) throws java.io.IOException
- Throws:
java.io.IOException
-
writeRectangle
protected void writeRectangle(JRPrintRectangle rectangle, TableCell cell) throws java.io.IOException
- Throws:
java.io.IOException
-
writeEllipse
protected void writeEllipse(JRPrintEllipse ellipse, TableCell cell) throws java.io.IOException
- Throws:
java.io.IOException
-
writeSvgStyle
protected void writeSvgStyle(JRPrintGraphicElement element) throws java.io.IOException
- Throws:
java.io.IOException
-
writeLine
protected void writeLine(JRPrintLine line, TableCell cell) throws java.io.IOException
- Throws:
java.io.IOException
-
isOblique
protected boolean isOblique(JRPrintLine line)
-
writeGenericElement
protected void writeGenericElement(JRGenericPrintElement element, TableCell cell) throws java.io.IOException, JRException
- Throws:
java.io.IOException
JRException
-
writeLayers
protected void writeLayers(java.util.List<Table> layers, HtmlExporter.TableVisitor tableVisitor, TableCell cell) throws java.io.IOException
- Throws:
java.io.IOException
-
writeNestedTable
protected void writeNestedTable(Table table, HtmlExporter.TableVisitor tableVisitor, TableCell cell) throws java.io.IOException
- Throws:
java.io.IOException
-
startCell
protected void startCell(JRPrintElement element, TableCell cell) throws java.io.IOException
- Throws:
java.io.IOException
-
getDataAttributes
public java.lang.String getDataAttributes(JRPrintElement element, TableCell cell)
-
getCellProperty
protected java.lang.String getCellProperty(JRPrintElement element, TableCell cell, java.lang.String key)
-
startCell
protected void startCell(TableCell cell) throws java.io.IOException
- Throws:
java.io.IOException
-
startCell
protected void startCell(int colSpan, int rowSpan, TableCell.CellType cellType) throws java.io.IOException
- Throws:
java.io.IOException
-
finishStartCell
protected void finishStartCell() throws java.io.IOException
- Throws:
java.io.IOException
-
endCell
protected void endCell(TableCell.CellType cellType) throws java.io.IOException
- Throws:
java.io.IOException
-
writeEmptyCell
protected void writeEmptyCell(int colSpan, int rowSpan) throws java.io.IOException
- Throws:
java.io.IOException
-
writeFrameCell
protected void writeFrameCell(TableCell cell) throws java.io.IOException
- Throws:
java.io.IOException
-
writeStyle
protected void writeStyle(java.lang.StringBuilder styleBuffer) throws java.io.IOException
- Throws:
java.io.IOException
-
appendElementCellGenericStyle
protected void appendElementCellGenericStyle(TableCell cell, java.lang.StringBuilder styleBuffer)
-
setBackcolor
protected void setBackcolor(java.awt.Color color)
-
restoreBackcolor
protected void restoreBackcolor()
-
matchesBackcolor
protected boolean matchesBackcolor(java.awt.Color backcolor)
-
appendBackcolorStyle
protected java.awt.Color appendBackcolorStyle(TableCell cell, java.lang.StringBuilder styleBuffer)
-
appendBorderStyle
protected boolean appendBorderStyle(JRLineBox box, java.lang.StringBuilder styleBuffer)
-
appendPen
protected boolean appendPen(java.lang.StringBuilder sb, JRPen pen, java.lang.String side)
-
appendPaddingStyle
protected boolean appendPaddingStyle(JRLineBox box, java.lang.StringBuilder styleBuffer)
-
appendPadding
protected boolean appendPadding(java.lang.StringBuilder sb, java.lang.Integer padding, java.lang.String side)
-
startHeading
protected AccessibilityTagEnum startHeading(JRPrintText text) throws java.io.IOException
- Throws:
java.io.IOException
-
endHeading
protected void endHeading(AccessibilityTagEnum headingTag) throws java.io.IOException
- Throws:
java.io.IOException
-
startHyperlink
protected boolean startHyperlink(JRPrintHyperlink link) throws java.io.IOException
- Throws:
java.io.IOException
-
endHyperlink
protected void endHyperlink() throws java.io.IOException
- Throws:
java.io.IOException
-
getHyperlinkURL
protected java.lang.String getHyperlinkURL(JRPrintHyperlink link)
-
resolveHyperlinkURL
protected java.lang.String resolveHyperlinkURL(int reportIndex, JRPrintHyperlink link)
-
getHyperlinkTarget
protected java.lang.String getHyperlinkTarget(JRPrintHyperlink link)
-
toSizeUnit
public java.lang.String toSizeUnit(float size)
-
toZoom
protected float toZoom(float size)
-
exportStyledText
protected void exportStyledText(JRPrintText printText, JRStyledText styledText, java.lang.String tooltip, boolean hyperlinkStarted) throws java.io.IOException
- Throws:
java.io.IOException
-
exportParagraph
protected void exportParagraph(StyledTextWriteContext context, JRPrintText printText, java.text.AttributedCharacterIterator allParagraphs, int paragraphStart, java.lang.String paragraphText, java.lang.Integer firstLineIndent, boolean justifyLastLine, java.lang.String tooltip, boolean hyperlinkStarted) throws java.io.IOException
- Throws:
java.io.IOException
-
exportStyledTextRun
protected void exportStyledTextRun(java.lang.String textRunStyle, java.util.Map<java.text.AttributedCharacterIterator.Attribute,java.lang.Object> attributes, java.lang.String text, java.lang.String tooltip, boolean hyperlinkStarted) throws java.io.IOException
- Throws:
java.io.IOException
-
getTextRunStyle
protected java.lang.String getTextRunStyle(java.util.Map<java.text.AttributedCharacterIterator.Attribute,java.lang.Object> attributes, java.util.Locale locale, LineSpacingEnum lineSpacing, java.lang.Float lineSpacingSize, float lineSpacingFactor, java.awt.Color backcolor, boolean hyperlinkStarted) throws java.io.IOException
- Throws:
java.io.IOException
-
-