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:
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 LinkedList<Color>
backcolorStack
static String
HTML_EXPORTER_KEY
The exporter key, as used inGenericElementHandlerEnviroment.getElementHandler(JRGenericElementType, String)
.static String
HTML_EXPORTER_PROPERTIES_PREFIX
protected Map<Pair<String,Rectangle>,String>
imageMaps
protected int
pageIndex
protected int
pointerEventsNoneStack
static 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 String
PROPERTY_HTML_ID
protected RenderersCache
renderersCache
protected Map<String,String>
rendererToImagePathMap
static String
REPORT_CONTEXT_PARAMETER_WEB_FONTS
protected int
reportIndex
protected ExporterFilter
tableFilter
protected JRHyperlinkTargetProducerFactory
targetProducerFactory
protected 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, fontsToProcess, HTML_VERTICAL_ALIGN_BOTTOM, HTML_VERTICAL_ALIGN_MIDDLE, HTML_VERTICAL_ALIGN_TOP, IMAGE_NAME_PREFIX, IMAGE_NAME_PREFIX_LEGTH, JR_BOOKMARK_ANCHOR_PREFIX, JR_PAGE_ANCHOR_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 HtmlExporter()
HtmlExporter(JasperReportsContext jasperReportsContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Color
appendBackcolorStyle(TableCell cell, StringBuilder styleBuffer)
protected boolean
appendBorderStyle(JRLineBox box, StringBuilder styleBuffer)
protected void
appendElementCellGenericStyle(TableCell cell, StringBuilder styleBuffer)
protected boolean
appendPadding(StringBuilder sb, Integer padding, String side)
protected boolean
appendPaddingStyle(JRLineBox box, StringBuilder styleBuffer)
protected boolean
appendPen(StringBuilder sb, JRPen pen, String side)
protected void
appendSizeStyle(int width, int height, StringBuilder styleBuffer)
protected void
endCell(TableCell.CellType cellType)
protected void
endHeading(AccessibilityTagEnum headingTag)
protected void
endHyperlink()
void
exportElements(List<JRPrintElement> elements)
protected void
exportPage(JRPrintPage page)
protected void
exportParagraph(StyledTextWriteContext context, JRPrintText printText, AttributedCharacterIterator allParagraphs, int paragraphStart, String paragraphText, Integer firstLineIndent, boolean justifyLastLine, String tooltip, boolean hyperlinkStarted)
void
exportReport()
Performs the export.protected void
exportReportToWriter()
protected void
exportStyledText(JRPrintText printText, JRStyledText styledText, String tooltip, boolean hyperlinkStarted)
protected void
exportStyledTextRun(String textRunStyle, Map<AttributedCharacterIterator.Attribute,Object> attributes, String text, String tooltip, boolean hyperlinkStarted)
protected void
exportTable(HtmlExporter.TableVisitor tableVisitor, Table table, boolean whiteBackground, boolean isMainReportTable)
protected void
finishStartCell()
protected String
getCellProperty(JRPrintElement element, TableCell cell, String key)
protected Class<HtmlExporterConfiguration>
getConfigurationInterface()
String
getDataAttributes(JRPrintElement element, TableCell cell)
protected JRPrintElementIndex
getElementIndex(TableCell cell)
String
getExporterKey()
String
getExporterPropertiesPrefix()
Returns the properties prefix for the current exporter.protected String
getHyperlinkTarget(JRPrintHyperlink link)
protected String
getHyperlinkURL(JRPrintHyperlink link)
protected String
getImageHorizontalAlignmentStyle(JRPrintImage image)
protected String
getImageVerticalAlignmentStyle(JRPrintImage image)
protected Class<HtmlReportConfiguration>
getItemConfigurationInterface()
protected String
getTextRunStyle(Map<AttributedCharacterIterator.Attribute,Object> attributes, Locale locale, LineSpacingEnum lineSpacing, Float lineSpacingSize, float lineSpacingFactor, Color backcolor, boolean hyperlinkStarted)
protected void
initExport()
protected void
initReport()
protected boolean
isOblique(JRPrintLine line)
protected boolean
matchesBackcolor(Color backcolor)
protected String
resolveHyperlinkURL(int reportIndex, JRPrintHyperlink link)
protected void
restoreBackcolor()
protected void
setBackcolor(Color color)
protected void
setJasperReportsContext(JasperReportsContext jasperReportsContext)
protected String
setRotationStyles(JRPrintText text, String horizontalAlignment, StringBuilder spanStyleBuffer, 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)
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(String imageMapName, JRPrintImage image, List<JRPrintImageAreaHyperlink> imageMapAreas)
protected void
writeLayers(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(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, getImage, getImage, getImageName, getPrintElementIndex, getStyledText, handleFont, isConvertSvgToImage, isEmbeddedSvgUseFonts, isEmbedImage, isOverrideHints, isUseBackgroundImageToAlign, resolveFontFamily
-
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, getTextFormatFactoryClass, getTextLocale, getTextTimeZone, getTextValue, getTextValueString, insideFrame, reset, resetExportContext, restoreElementOffsets, setConfiguration, setConfiguration, setCurrentExporterInputItem, setExporterInput, setExporterOutput, setFrameElementsOffset, setOffset, setOffset, 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 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 String PROPERTY_HTML_ID
- See Also:
- Constant Field Values
-
REPORT_CONTEXT_PARAMETER_WEB_FONTS
public static final String REPORT_CONTEXT_PARAMETER_WEB_FONTS
- 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:
getExporterKey
in classJRAbstractExporter<HtmlReportConfiguration,HtmlExporterConfiguration,HtmlExporterOutput,JRHtmlExporterContext>
-
getExporterPropertiesPrefix
public 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 Class<HtmlExporterConfiguration> getConfigurationInterface()
-
getItemConfigurationInterface
protected Class<HtmlReportConfiguration> getItemConfigurationInterface()
-
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, IOException
- Throws:
JRException
IOException
-
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:
IOException
JRException
-
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:
IOException
JRException
-
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
-
-