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 classHtmlExporter.CellElementVisitorprotected classHtmlExporter.ExporterContextprotected classHtmlExporter.HtmlStyledTextListWriterprotected classHtmlExporter.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>backcolorStackstatic java.lang.StringHTML_EXPORTER_KEYThe exporter key, as used inGenericElementHandlerEnviroment.getElementHandler(JRGenericElementType, String).static java.lang.StringHTML_EXPORTER_PROPERTIES_PREFIXprotected java.util.Map<Pair<java.lang.String,java.awt.Rectangle>,java.lang.String>imageMapsprotected intpageIndexprotected intpointerEventsNoneStackstatic java.lang.StringPROPERTY_HTML_CLASSProperty that provides the value for theclassCSS style property to be applied to elements in the table generated for the report.static java.lang.StringPROPERTY_HTML_IDprotected RenderersCacherenderersCacheprotected java.util.Map<java.lang.String,java.lang.String>rendererToImagePathMapprotected intreportIndexprotected ExporterFiltertableFilterprotected JRHyperlinkTargetProducerFactorytargetProducerFactoryprotected java.io.Writerwriter-
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.ColorappendBackcolorStyle(TableCell cell, java.lang.StringBuilder styleBuffer)protected booleanappendBorderStyle(JRLineBox box, java.lang.StringBuilder styleBuffer)protected voidappendElementCellGenericStyle(TableCell cell, java.lang.StringBuilder styleBuffer)protected booleanappendPadding(java.lang.StringBuilder sb, java.lang.Integer padding, java.lang.String side)protected booleanappendPaddingStyle(JRLineBox box, java.lang.StringBuilder styleBuffer)protected booleanappendPen(java.lang.StringBuilder sb, JRPen pen, java.lang.String side)protected voidappendSizeStyle(int width, int height, java.lang.StringBuilder styleBuffer)protected voidendCell(TableCell.CellType cellType)protected voidendHeading(AccessibilityTagEnum headingTag)protected voidendHyperlink()protected voidensureOutput()voidexportElements(java.util.List<JRPrintElement> elements)protected voidexportPage(JRPrintPage page)protected voidexportParagraph(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)voidexportReport()Performs the export.protected voidexportReportToWriter()protected voidexportStyledText(JRPrintText printText, JRStyledText styledText, java.lang.String tooltip, boolean hyperlinkStarted)protected voidexportStyledTextRun(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 voidexportTable(HtmlExporter.TableVisitor tableVisitor, Table table, boolean whiteBackground, boolean isMainReportTable)protected voidfinishStartCell()protected java.lang.StringgetCellProperty(JRPrintElement element, TableCell cell, java.lang.String key)protected java.lang.Class<HtmlExporterConfiguration>getConfigurationInterface()java.lang.StringgetDataAttributes(JRPrintElement element, TableCell cell)protected JRPrintElementIndexgetElementIndex(TableCell cell)java.lang.StringgetExporterKey()java.lang.StringgetExporterPropertiesPrefix()Returns the properties prefix for the current exporter.protected java.lang.StringgetHyperlinkTarget(JRPrintHyperlink link)protected java.lang.StringgetHyperlinkURL(JRPrintHyperlink link)protected java.lang.StringgetImageHorizontalAlignmentStyle(JRPrintImage image)protected java.lang.StringgetImageVerticalAlignmentStyle(JRPrintImage image)protected java.lang.Class<HtmlReportConfiguration>getItemConfigurationInterface()protected java.lang.StringgetTextRunStyle(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 voidinitExport()protected voidinitReport()protected booleanisOblique(JRPrintLine line)protected booleanmatchesBackcolor(java.awt.Color backcolor)protected java.lang.StringresolveHyperlinkURL(int reportIndex, JRPrintHyperlink link)protected voidrestoreBackcolor()protected voidsetBackcolor(java.awt.Color color)protected voidsetJasperReportsContext(JasperReportsContext jasperReportsContext)protected java.lang.StringsetRotationStyles(JRPrintText text, java.lang.String horizontalAlignment, java.lang.StringBuilder spanStyleBuffer, java.lang.StringBuilder divStyleBuffer)protected voidstartCell(int colSpan, int rowSpan, TableCell.CellType cellType)protected voidstartCell(TableCell cell)protected voidstartCell(JRPrintElement element, TableCell cell)protected AccessibilityTagEnumstartHeading(JRPrintText text)protected booleanstartHyperlink(JRPrintHyperlink link)java.lang.StringtoSizeUnit(float size)protected floattoZoom(float size)protected voidwriteEllipse(JRPrintEllipse ellipse, TableCell cell)protected voidwriteEmptyCell(int colSpan, int rowSpan)protected voidwriteFrameCell(TableCell cell)protected voidwriteGenericElement(JRGenericPrintElement element, TableCell cell)voidwriteImage(JRPrintImage image, TableCell cell)protected voidwriteImageAreaCoordinates(int[] coords)protected voidwriteImageAreaHyperlink(JRPrintHyperlink hyperlink)protected voidwriteImageMap(java.lang.String imageMapName, JRPrintImage image, java.util.List<JRPrintImageAreaHyperlink> imageMapAreas)protected voidwriteLayers(java.util.List<Table> layers, HtmlExporter.TableVisitor tableVisitor, TableCell cell)protected voidwriteLine(JRPrintLine line, TableCell cell)protected voidwriteNestedTable(Table table, HtmlExporter.TableVisitor tableVisitor, TableCell cell)protected voidwriteRectangle(JRPrintRectangle rectangle, TableCell cell)protected voidwriteStyle(java.lang.StringBuilder styleBuffer)protected voidwriteSvgStyle(JRPrintGraphicElement element)protected voidwriteText(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 theclassCSS 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 theclassattribute of the<td>tag for the element when exported to HTML and/or theclassattribute 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:
getExporterKeyin classJRAbstractExporter<HtmlReportConfiguration,HtmlExporterConfiguration,HtmlExporterOutput,JRHtmlExporterContext>
-
getExporterPropertiesPrefix
public java.lang.String getExporterPropertiesPrefix()
Description copied from class:JRAbstractExporterReturns the properties prefix for the current exporter.- Specified by:
getExporterPropertiesPrefixin classJRAbstractExporter<HtmlReportConfiguration,HtmlExporterConfiguration,HtmlExporterOutput,JRHtmlExporterContext>- Returns:
- the properties prefix for the current exporter
-
exportReport
public void exportReport() throws JRExceptionDescription copied from interface:ExporterPerforms the export.- Specified by:
exportReportin interfaceExporter<ExporterInput,HtmlReportConfiguration,HtmlExporterConfiguration,HtmlExporterOutput>- Specified by:
exportReportin 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:
ensureOutputin classJRAbstractExporter<HtmlReportConfiguration,HtmlExporterConfiguration,HtmlExporterOutput,JRHtmlExporterContext>
-
initExport
protected void initExport()
- Overrides:
initExportin classJRAbstractExporter<HtmlReportConfiguration,HtmlExporterConfiguration,HtmlExporterOutput,JRHtmlExporterContext>
-
initReport
protected void initReport()
- Overrides:
initReportin classJRAbstractExporter<HtmlReportConfiguration,HtmlExporterConfiguration,HtmlExporterOutput,JRHtmlExporterContext>
-
setJasperReportsContext
protected void setJasperReportsContext(JasperReportsContext jasperReportsContext)
-
exportReportToWriter
protected void exportReportToWriter() throws JRException, java.io.IOException- Throws:
JRExceptionjava.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.IOExceptionJRException
-
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.IOExceptionJRException
-
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
-
-