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 LinkedList<Color>backcolorStackstatic StringHTML_EXPORTER_KEYThe exporter key, as used inGenericElementHandlerEnviroment.getElementHandler(JRGenericElementType, String).static StringHTML_EXPORTER_PROPERTIES_PREFIXprotected Map<Pair<String,Rectangle>,String>imageMapsprotected intpageIndexprotected intpointerEventsNoneStackstatic StringPROPERTY_HTML_CLASSProperty that provides the value for theclassCSS style property to be applied to elements in the table generated for the report.static StringPROPERTY_HTML_IDprotected RenderersCacherenderersCacheprotected Map<String,String>rendererToImagePathMapprotected intreportIndexprotected ExporterFiltertableFilterprotected JRHyperlinkTargetProducerFactorytargetProducerFactoryprotected 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 ColorappendBackcolorStyle(TableCell cell, StringBuilder styleBuffer)protected booleanappendBorderStyle(JRLineBox box, StringBuilder styleBuffer)protected voidappendElementCellGenericStyle(TableCell cell, StringBuilder styleBuffer)protected booleanappendPadding(StringBuilder sb, Integer padding, String side)protected booleanappendPaddingStyle(JRLineBox box, StringBuilder styleBuffer)protected booleanappendPen(StringBuilder sb, JRPen pen, String side)protected voidappendSizeStyle(int width, int height, StringBuilder styleBuffer)protected voidendCell(TableCell.CellType cellType)protected voidendHeading(AccessibilityTagEnum headingTag)protected voidendHyperlink()protected voidensureOutput()voidexportElements(List<JRPrintElement> elements)protected voidexportPage(JRPrintPage page)protected voidexportParagraph(StyledTextWriteContext context, JRPrintText printText, AttributedCharacterIterator allParagraphs, int paragraphStart, String paragraphText, Integer firstLineIndent, boolean justifyLastLine, String tooltip, boolean hyperlinkStarted)voidexportReport()Performs the export.protected voidexportReportToWriter()protected voidexportStyledText(JRPrintText printText, JRStyledText styledText, String tooltip, boolean hyperlinkStarted)protected voidexportStyledTextRun(String textRunStyle, Map<AttributedCharacterIterator.Attribute,Object> attributes, String text, String tooltip, boolean hyperlinkStarted)protected voidexportTable(HtmlExporter.TableVisitor tableVisitor, Table table, boolean whiteBackground, boolean isMainReportTable)protected voidfinishStartCell()protected StringgetCellProperty(JRPrintElement element, TableCell cell, String key)protected Class<HtmlExporterConfiguration>getConfigurationInterface()StringgetDataAttributes(JRPrintElement element, TableCell cell)protected JRPrintElementIndexgetElementIndex(TableCell cell)StringgetExporterKey()StringgetExporterPropertiesPrefix()Returns the properties prefix for the current exporter.protected StringgetHyperlinkTarget(JRPrintHyperlink link)protected StringgetHyperlinkURL(JRPrintHyperlink link)protected StringgetImageHorizontalAlignmentStyle(JRPrintImage image)protected StringgetImageVerticalAlignmentStyle(JRPrintImage image)protected Class<HtmlReportConfiguration>getItemConfigurationInterface()protected StringgetTextRunStyle(Map<AttributedCharacterIterator.Attribute,Object> attributes, Locale locale, LineSpacingEnum lineSpacing, Float lineSpacingSize, float lineSpacingFactor, Color backcolor, boolean hyperlinkStarted)protected voidinitExport()protected voidinitReport()protected booleanisOblique(JRPrintLine line)protected booleanmatchesBackcolor(Color backcolor)protected StringresolveHyperlinkURL(int reportIndex, JRPrintHyperlink link)protected voidrestoreBackcolor()protected voidsetBackcolor(Color color)protected voidsetJasperReportsContext(JasperReportsContext jasperReportsContext)protected StringsetRotationStyles(JRPrintText text, String horizontalAlignment, StringBuilder spanStyleBuffer, 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)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(String imageMapName, JRPrintImage image, List<JRPrintImageAreaHyperlink> imageMapAreas)protected voidwriteLayers(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(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 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 String HTML_EXPORTER_PROPERTIES_PREFIX
- See Also:
- Constant Field Values
-
PROPERTY_HTML_CLASS
public static final 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 String PROPERTY_HTML_ID
- See Also:
- Constant Field Values
-
targetProducerFactory
protected JRHyperlinkTargetProducerFactory targetProducerFactory
-
renderersCache
protected RenderersCache renderersCache
-
writer
protected Writer writer
-
reportIndex
protected int reportIndex
-
pageIndex
protected int pageIndex
-
backcolorStack
protected LinkedList<Color> backcolorStack
-
tableFilter
protected ExporterFilter tableFilter
-
pointerEventsNoneStack
protected int pointerEventsNoneStack
-
-
Constructor Detail
-
HtmlExporter
public HtmlExporter()
-
HtmlExporter
public HtmlExporter(JasperReportsContext jasperReportsContext)
-
-
Method Detail
-
getExporterKey
public String getExporterKey()
- Specified by:
getExporterKeyin classJRAbstractExporter<HtmlReportConfiguration,HtmlExporterConfiguration,HtmlExporterOutput,JRHtmlExporterContext>
-
getExporterPropertiesPrefix
public 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 Class<HtmlExporterConfiguration> getConfigurationInterface()
-
getItemConfigurationInterface
protected 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, IOException- Throws:
JRExceptionIOException
-
exportPage
protected void exportPage(JRPrintPage page) throws IOException
- Throws:
IOException
-
exportElements
public void exportElements(List<JRPrintElement> elements) throws IOException
- Throws:
IOException
-
exportTable
protected void exportTable(HtmlExporter.TableVisitor tableVisitor, Table table, boolean whiteBackground, boolean isMainReportTable) throws IOException
- Throws:
IOException
-
writeText
protected void writeText(JRPrintText text, TableCell cell) throws IOException
- Throws:
IOException
-
setRotationStyles
protected String setRotationStyles(JRPrintText text, String horizontalAlignment, StringBuilder spanStyleBuffer, StringBuilder divStyleBuffer)
-
appendSizeStyle
protected void appendSizeStyle(int width, int height, StringBuilder styleBuffer)
-
writeImage
public void writeImage(JRPrintImage image, TableCell cell) throws IOException, JRException
- Throws:
IOExceptionJRException
-
getImageHorizontalAlignmentStyle
protected String getImageHorizontalAlignmentStyle(JRPrintImage image)
-
getImageVerticalAlignmentStyle
protected String getImageVerticalAlignmentStyle(JRPrintImage image)
-
getElementIndex
protected JRPrintElementIndex getElementIndex(TableCell cell)
-
writeImageMap
protected void writeImageMap(String imageMapName, JRPrintImage image, List<JRPrintImageAreaHyperlink> imageMapAreas) throws IOException
- Throws:
IOException
-
writeImageAreaCoordinates
protected void writeImageAreaCoordinates(int[] coords) throws IOException- Throws:
IOException
-
writeImageAreaHyperlink
protected void writeImageAreaHyperlink(JRPrintHyperlink hyperlink) throws IOException
- Throws:
IOException
-
writeRectangle
protected void writeRectangle(JRPrintRectangle rectangle, TableCell cell) throws IOException
- Throws:
IOException
-
writeEllipse
protected void writeEllipse(JRPrintEllipse ellipse, TableCell cell) throws IOException
- Throws:
IOException
-
writeSvgStyle
protected void writeSvgStyle(JRPrintGraphicElement element) throws IOException
- Throws:
IOException
-
writeLine
protected void writeLine(JRPrintLine line, TableCell cell) throws IOException
- Throws:
IOException
-
isOblique
protected boolean isOblique(JRPrintLine line)
-
writeGenericElement
protected void writeGenericElement(JRGenericPrintElement element, TableCell cell) throws IOException, JRException
- Throws:
IOExceptionJRException
-
writeLayers
protected void writeLayers(List<Table> layers, HtmlExporter.TableVisitor tableVisitor, TableCell cell) throws IOException
- Throws:
IOException
-
writeNestedTable
protected void writeNestedTable(Table table, HtmlExporter.TableVisitor tableVisitor, TableCell cell) throws IOException
- Throws:
IOException
-
startCell
protected void startCell(JRPrintElement element, TableCell cell) throws IOException
- Throws:
IOException
-
getDataAttributes
public String getDataAttributes(JRPrintElement element, TableCell cell)
-
getCellProperty
protected String getCellProperty(JRPrintElement element, TableCell cell, String key)
-
startCell
protected void startCell(TableCell cell) throws IOException
- Throws:
IOException
-
startCell
protected void startCell(int colSpan, int rowSpan, TableCell.CellType cellType) throws IOException- Throws:
IOException
-
finishStartCell
protected void finishStartCell() throws IOException- Throws:
IOException
-
endCell
protected void endCell(TableCell.CellType cellType) throws IOException
- Throws:
IOException
-
writeEmptyCell
protected void writeEmptyCell(int colSpan, int rowSpan) throws IOException- Throws:
IOException
-
writeFrameCell
protected void writeFrameCell(TableCell cell) throws IOException
- Throws:
IOException
-
writeStyle
protected void writeStyle(StringBuilder styleBuffer) throws IOException
- Throws:
IOException
-
appendElementCellGenericStyle
protected void appendElementCellGenericStyle(TableCell cell, StringBuilder styleBuffer)
-
setBackcolor
protected void setBackcolor(Color color)
-
restoreBackcolor
protected void restoreBackcolor()
-
matchesBackcolor
protected boolean matchesBackcolor(Color backcolor)
-
appendBackcolorStyle
protected Color appendBackcolorStyle(TableCell cell, StringBuilder styleBuffer)
-
appendBorderStyle
protected boolean appendBorderStyle(JRLineBox box, StringBuilder styleBuffer)
-
appendPen
protected boolean appendPen(StringBuilder sb, JRPen pen, String side)
-
appendPaddingStyle
protected boolean appendPaddingStyle(JRLineBox box, StringBuilder styleBuffer)
-
appendPadding
protected boolean appendPadding(StringBuilder sb, Integer padding, String side)
-
startHeading
protected AccessibilityTagEnum startHeading(JRPrintText text) throws IOException
- Throws:
IOException
-
endHeading
protected void endHeading(AccessibilityTagEnum headingTag) throws IOException
- Throws:
IOException
-
startHyperlink
protected boolean startHyperlink(JRPrintHyperlink link) throws IOException
- Throws:
IOException
-
endHyperlink
protected void endHyperlink() throws IOException- Throws:
IOException
-
getHyperlinkURL
protected String getHyperlinkURL(JRPrintHyperlink link)
-
resolveHyperlinkURL
protected String resolveHyperlinkURL(int reportIndex, JRPrintHyperlink link)
-
getHyperlinkTarget
protected String getHyperlinkTarget(JRPrintHyperlink link)
-
toSizeUnit
public String toSizeUnit(float size)
-
toZoom
protected float toZoom(float size)
-
exportStyledText
protected void exportStyledText(JRPrintText printText, JRStyledText styledText, String tooltip, boolean hyperlinkStarted) throws IOException
- Throws:
IOException
-
exportParagraph
protected void exportParagraph(StyledTextWriteContext context, JRPrintText printText, AttributedCharacterIterator allParagraphs, int paragraphStart, String paragraphText, Integer firstLineIndent, boolean justifyLastLine, String tooltip, boolean hyperlinkStarted) throws IOException
- Throws:
IOException
-
exportStyledTextRun
protected void exportStyledTextRun(String textRunStyle, Map<AttributedCharacterIterator.Attribute,Object> attributes, String text, String tooltip, boolean hyperlinkStarted) throws IOException
- Throws:
IOException
-
getTextRunStyle
protected String getTextRunStyle(Map<AttributedCharacterIterator.Attribute,Object> attributes, Locale locale, LineSpacingEnum lineSpacing, Float lineSpacingSize, float lineSpacingFactor, Color backcolor, boolean hyperlinkStarted) throws IOException
- Throws:
IOException
-
-