net.sf.jasperreports.engine.export
Class JRXhtmlExporter

java.lang.Object
  extended by net.sf.jasperreports.engine.JRAbstractExporter
      extended by net.sf.jasperreports.engine.export.JRXhtmlExporter
All Implemented Interfaces:
JRExporter

public class JRXhtmlExporter
extends JRAbstractExporter

Exports a JasperReports document to XHTML format.

Version:
$Id: JRXhtmlExporter.java 5166 2012-03-28 13:11:05Z teodord $
Author:
Teodor Danciu (teodord@users.sourceforge.net)

Nested Class Summary
protected  class JRXhtmlExporter.ExporterContext
           
 
Nested classes/interfaces inherited from class net.sf.jasperreports.engine.JRAbstractExporter
JRAbstractExporter.BaseExporterContext, JRAbstractExporter.ParameterOverriddenResolver, JRAbstractExporter.ParameterOverrideResolver, JRAbstractExporter.ParameterResolver
 
Field Summary
protected  String betweenPagesHtml
           
protected  int bottomLimit
           
protected static String CSS_TEXT_ALIGN_CENTER
           
protected static String CSS_TEXT_ALIGN_JUSTIFY
           
protected static String CSS_TEXT_ALIGN_LEFT
           
protected static String CSS_TEXT_ALIGN_RIGHT
           
protected static float DEFAULT_ZOOM
           
protected  int elementIndex
           
protected  String encoding
           
protected  JRHtmlExporterContext exporterContext
           
protected  List<net.sf.jasperreports.engine.export.JRXhtmlExporter.FrameInfo> frameInfoStack
           
protected static String HTML_VERTICAL_ALIGN_BOTTOM
           
protected static String HTML_VERTICAL_ALIGN_MIDDLE
           
protected static String HTML_VERTICAL_ALIGN_TOP
           
protected  String htmlFooter
           
protected  String htmlHeader
           
protected  boolean hyperlinkStarted
           
static String IMAGE_NAME_PREFIX
           
protected static int IMAGE_NAME_PREFIX_LEGTH
           
protected  Map<Pair<String,Rectangle>,String> imageMaps
           
protected  Map<String,byte[]> imageNameToImageDataMap
           
protected  File imagesDir
           
protected  List<JRPrintElementIndex> imagesToProcess
           
protected  String imagesURI
           
protected  boolean isIgnorePageMargins
           
protected  boolean isOutputImagesToDir
           
protected  boolean isWhitePageBackground
           
protected  boolean isWrapBreakWord
           
protected static String JR_PAGE_ANCHOR_PREFIX
           
protected  int leftLimit
           
protected  int pageIndex
           
protected  JRExportProgressMonitor progressMonitor
           
protected  Map<String,String> rendererToImagePathMap
           
protected  int reportIndex
           
protected  int rightLimit
           
protected  String sizeUnit
           
protected  JRHyperlinkTargetProducerFactory targetProducerFactory
           
protected  int topLimit
           
protected  Writer writer
           
static String XHTML_EXPORTER_KEY
          The exporter key, as used in GenericElementHandlerEnviroment.getHandler(net.sf.jasperreports.engine.JRGenericElementType, String).
protected  float zoom
           
 
Fields inherited from class net.sf.jasperreports.engine.JRAbstractExporter
dateFormatCache, endPageIndex, filter, fontMap, globalOffsetX, globalOffsetY, hyperlinkProducerFactory, isModeBatch, jasperPrint, jasperPrintList, jasperReportsContext, numberFormatCache, parameters, PROPERTY_DEFAULT_FILTER_FACTORY, PROPERTY_SUFFIX_DEFAULT_FILTER_FACTORY, startPageIndex
 
Constructor Summary
JRXhtmlExporter()
           
JRXhtmlExporter(JasperReportsContext jasperReportsContext)
           
 
Method Summary
protected  void appendBackcolorStyle(JRPrintElement element, StringBuffer styleBuffer)
           
protected  boolean appendBorderStyle(JRLineBox box, StringBuffer styleBuffer)
           
protected  void appendPositionStyle(int x, int y, StringBuffer styleBuffer)
           
protected  void appendPositionStyle(JRPrintElement element, JRBoxContainer boxContainer, StringBuffer styleBuffer)
           
protected  void appendPositionStyle(JRPrintElement element, JRPen pen, StringBuffer styleBuffer)
           
protected  void appendSizeStyle(int width, int height, StringBuffer styleBuffer)
           
protected  void appendSizeStyle(JRPrintElement element, JRBoxContainer boxContainer, StringBuffer styleBuffer)
           
protected  void appendSizeStyle(JRPrintElement element, JRPen pen, StringBuffer styleBuffer)
           
protected  void endHyperlink()
           
protected  void exportElements(List<JRPrintElement> elements)
           
protected  void exportFrame(JRPrintFrame frame)
           
protected  void exportGenericElement(JRGenericPrintElement element)
           
protected  void exportImage(JRPrintImage image)
           
protected  void exportLine(JRPrintLine line)
           
protected  void exportPage(JRPrintPage page)
           
protected  void exportRectangle(JRPrintGraphicElement element)
           
 void exportReport()
          Actually starts the export process.
protected  void exportReportToWriter()
           
protected  void exportStyledText(JRStyledText styledText, Locale locale)
           
protected  void exportStyledText(JRStyledText styledText, String tooltip, Locale locale)
           
protected  void exportStyledTextRun(Map<AttributedCharacterIterator.Attribute,Object> attributes, String text, Locale locale)
           
protected  void exportStyledTextRun(Map<AttributedCharacterIterator.Attribute,Object> attributes, String text, String tooltip, Locale locale)
           
protected  void exportText(JRPrintText text)
           
protected  JRPrintElementIndex getElementIndex()
           
 JasperPrint getExportedReport()
           
protected  String getExporterKey()
           
 Map<JRExporterParameter,Object> getExportParameters()
           
 String getExportPropertiesPrefix()
           
protected  String getHyperlinkTarget(JRPrintHyperlink link)
           
protected  String getHyperlinkURL(JRPrintHyperlink link)
           
static JRPrintImage getImage(List<JasperPrint> jasperPrintList, JRPrintElementIndex imageIndex)
           
static JRPrintImage getImage(List<JasperPrint> jasperPrintList, String imageName)
           
static String getImageName(JRPrintElementIndex printElementIndex)
           
protected  int getInsideBorderOffset(float borderWidth, boolean small)
           
static JRPrintElementIndex getPrintElementIndex(String imageName)
           
protected  JRStyledText getStyledText(JRPrintText textElement, boolean setBackcolor)
           
protected  boolean startHyperlink(JRPrintHyperlink link)
           
 String toSizeUnit(int size)
           
 int toZoom(int size)
           
protected  void writeImageAreaCoordinates(int[] coords)
           
protected  void writeImageAreaHyperlink(JRPrintHyperlink hyperlink)
           
protected  void writeImageMap(String imageMapName, JRPrintImage image, List<JRPrintImageAreaHyperlink> imageMapAreas)
           
 
Methods inherited from class net.sf.jasperreports.engine.JRAbstractExporter
createFilter, defaultParseNumber, getBooleanCellValue, getBooleanParameter, getCharacterParameter, getCustomHandler, getDateCellValue, getDateFormat, getFloatParameter, getHyperlinkProducer, getIntegerParameter, getJasperReportsContext, getLocale, getNumberCellValue, getNumberFormat, getOffsetX, getOffsetY, getParameter, getParameterResolver, getParameters, getPropertiesUtil, getReportContext, getStringArrayParameter, getStringParameter, getStringParameterOrDefault, getStyledText, getTextFormatFactoryClass, getTextLocale, getTextTimeZone, getTextValue, getTextValueString, reset, resetClassLoader, resetExportContext, restoreElementOffsets, setClassLoader, setExportContext, setFontMap, setFrameElementsOffset, setHyperlinkProducerFactory, setInput, setJasperPrint, setOffset, setOffset, setOutput, setPageRange, setParameter, setParameters, setReportContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XHTML_EXPORTER_KEY

public static final String XHTML_EXPORTER_KEY
The exporter key, as used in GenericElementHandlerEnviroment.getHandler(net.sf.jasperreports.engine.JRGenericElementType, String).

See Also:
Constant Field Values

JR_PAGE_ANCHOR_PREFIX

protected static final String JR_PAGE_ANCHOR_PREFIX
See Also:
Constant Field Values

DEFAULT_ZOOM

protected static final float DEFAULT_ZOOM
See Also:
Constant Field Values

CSS_TEXT_ALIGN_LEFT

protected static final String CSS_TEXT_ALIGN_LEFT
See Also:
Constant Field Values

CSS_TEXT_ALIGN_RIGHT

protected static final String CSS_TEXT_ALIGN_RIGHT
See Also:
Constant Field Values

CSS_TEXT_ALIGN_CENTER

protected static final String CSS_TEXT_ALIGN_CENTER
See Also:
Constant Field Values

CSS_TEXT_ALIGN_JUSTIFY

protected static final String CSS_TEXT_ALIGN_JUSTIFY
See Also:
Constant Field Values

HTML_VERTICAL_ALIGN_TOP

protected static final String HTML_VERTICAL_ALIGN_TOP
See Also:
Constant Field Values

HTML_VERTICAL_ALIGN_MIDDLE

protected static final String HTML_VERTICAL_ALIGN_MIDDLE
See Also:
Constant Field Values

HTML_VERTICAL_ALIGN_BOTTOM

protected static final String HTML_VERTICAL_ALIGN_BOTTOM
See Also:
Constant Field Values

IMAGE_NAME_PREFIX

public static final String IMAGE_NAME_PREFIX
See Also:
Constant Field Values

IMAGE_NAME_PREFIX_LEGTH

protected static final int IMAGE_NAME_PREFIX_LEGTH

writer

protected Writer writer

progressMonitor

protected JRExportProgressMonitor progressMonitor

rendererToImagePathMap

protected Map<String,String> rendererToImagePathMap

imageMaps

protected Map<Pair<String,Rectangle>,String> imageMaps

imageNameToImageDataMap

protected Map<String,byte[]> imageNameToImageDataMap

imagesToProcess

protected List<JRPrintElementIndex> imagesToProcess

reportIndex

protected int reportIndex

pageIndex

protected int pageIndex

frameInfoStack

protected List<net.sf.jasperreports.engine.export.JRXhtmlExporter.FrameInfo> frameInfoStack

elementIndex

protected int elementIndex

topLimit

protected int topLimit

leftLimit

protected int leftLimit

rightLimit

protected int rightLimit

bottomLimit

protected int bottomLimit

imagesDir

protected File imagesDir

imagesURI

protected String imagesURI

isOutputImagesToDir

protected boolean isOutputImagesToDir

isWhitePageBackground

protected boolean isWhitePageBackground

encoding

protected String encoding

sizeUnit

protected String sizeUnit

zoom

protected float zoom

isWrapBreakWord

protected boolean isWrapBreakWord

isIgnorePageMargins

protected boolean isIgnorePageMargins

htmlHeader

protected String htmlHeader

betweenPagesHtml

protected String betweenPagesHtml

htmlFooter

protected String htmlFooter

targetProducerFactory

protected JRHyperlinkTargetProducerFactory targetProducerFactory

hyperlinkStarted

protected boolean hyperlinkStarted

exporterContext

protected JRHtmlExporterContext exporterContext
Constructor Detail

JRXhtmlExporter

public JRXhtmlExporter()
See Also:
JRXhtmlExporter(JasperReportsContext)

JRXhtmlExporter

public JRXhtmlExporter(JasperReportsContext jasperReportsContext)
Method Detail

exportReport

public void exportReport()
                  throws JRException
Description copied from interface: JRExporter
Actually starts the export process.

Specified by:
exportReport in interface JRExporter
Specified by:
exportReport in class JRAbstractExporter
Throws:
JRException

getImage

public static JRPrintImage getImage(List<JasperPrint> jasperPrintList,
                                    String imageName)

getImage

public static JRPrintImage getImage(List<JasperPrint> jasperPrintList,
                                    JRPrintElementIndex imageIndex)

exportReportToWriter

protected void exportReportToWriter()
                             throws JRException,
                                    IOException
Throws:
JRException
IOException

exportPage

protected void exportPage(JRPrintPage page)
                   throws JRException,
                          IOException
Throws:
JRException
IOException

exportElements

protected void exportElements(List<JRPrintElement> elements)
                       throws IOException,
                              JRException
Throws:
IOException
JRException

exportLine

protected void exportLine(JRPrintLine line)
                   throws IOException
Throws:
IOException

exportRectangle

protected void exportRectangle(JRPrintGraphicElement element)
                        throws IOException
Throws:
IOException

exportStyledText

protected void exportStyledText(JRStyledText styledText,
                                Locale locale)
                         throws IOException
Throws:
IOException

exportStyledText

protected void exportStyledText(JRStyledText styledText,
                                String tooltip,
                                Locale locale)
                         throws IOException
Throws:
IOException

exportStyledTextRun

protected void exportStyledTextRun(Map<AttributedCharacterIterator.Attribute,Object> attributes,
                                   String text,
                                   Locale locale)
                            throws IOException
Throws:
IOException

exportStyledTextRun

protected void exportStyledTextRun(Map<AttributedCharacterIterator.Attribute,Object> attributes,
                                   String text,
                                   String tooltip,
                                   Locale locale)
                            throws IOException
Throws:
IOException

exportText

protected void exportText(JRPrintText text)
                   throws IOException
Throws:
IOException

startHyperlink

protected boolean startHyperlink(JRPrintHyperlink link)
                          throws IOException
Throws:
IOException

getHyperlinkTarget

protected String getHyperlinkTarget(JRPrintHyperlink link)

getHyperlinkURL

protected String getHyperlinkURL(JRPrintHyperlink link)

endHyperlink

protected void endHyperlink()
                     throws IOException
Throws:
IOException

appendBorderStyle

protected boolean appendBorderStyle(JRLineBox box,
                                    StringBuffer styleBuffer)

getInsideBorderOffset

protected int getInsideBorderOffset(float borderWidth,
                                    boolean small)

appendSizeStyle

protected void appendSizeStyle(JRPrintElement element,
                               JRBoxContainer boxContainer,
                               StringBuffer styleBuffer)

appendSizeStyle

protected void appendSizeStyle(JRPrintElement element,
                               JRPen pen,
                               StringBuffer styleBuffer)

appendSizeStyle

protected void appendSizeStyle(int width,
                               int height,
                               StringBuffer styleBuffer)

appendPositionStyle

protected void appendPositionStyle(JRPrintElement element,
                                   JRBoxContainer boxContainer,
                                   StringBuffer styleBuffer)

appendPositionStyle

protected void appendPositionStyle(JRPrintElement element,
                                   JRPen pen,
                                   StringBuffer styleBuffer)

appendPositionStyle

protected void appendPositionStyle(int x,
                                   int y,
                                   StringBuffer styleBuffer)

appendBackcolorStyle

protected void appendBackcolorStyle(JRPrintElement element,
                                    StringBuffer styleBuffer)

exportImage

protected void exportImage(JRPrintImage image)
                    throws JRException,
                           IOException
Throws:
JRException
IOException

getElementIndex

protected JRPrintElementIndex getElementIndex()

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

getImageName

public static String getImageName(JRPrintElementIndex printElementIndex)

getPrintElementIndex

public static JRPrintElementIndex getPrintElementIndex(String imageName)

exportFrame

protected void exportFrame(JRPrintFrame frame)
                    throws IOException,
                           JRException
Throws:
IOException
JRException

exportGenericElement

protected void exportGenericElement(JRGenericPrintElement element)
                             throws IOException
Throws:
IOException

getExportParameters

public Map<JRExporterParameter,Object> getExportParameters()

getExportPropertiesPrefix

public String getExportPropertiesPrefix()

getExportedReport

public JasperPrint getExportedReport()

toSizeUnit

public String toSizeUnit(int size)

toZoom

public int toZoom(int size)

getStyledText

protected JRStyledText getStyledText(JRPrintText textElement,
                                     boolean setBackcolor)
Overrides:
getStyledText in class JRAbstractExporter

getExporterKey

protected String getExporterKey()
Specified by:
getExporterKey in class JRAbstractExporter


Copyright © 2012. All Rights Reserved.