Class JasperPrint
- java.lang.Object
-
- net.sf.jasperreports.engine.JasperPrint
-
- All Implemented Interfaces:
Serializable,JRChangeEventsSupport,JRPropertiesHolder
- Direct Known Subclasses:
ReadOnlyPartJasperPrint
public class JasperPrint extends Object implements Serializable, JRPropertiesHolder, JRChangeEventsSupport
An instance of this class represents a page-oriented document that can be viewed, printed or exported to other formats.When filling report designs with data, the engine produces instances of this class and these can be transferred over the network, stored in a serialized form on disk or exported to various other formats like PDF, HTML, XLS, CSV or XML.
- Author:
- Teodor Danciu (teodord@users.sourceforge.net)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringEXCEPTION_MESSAGE_KEY_DUPLICATE_STYLEstatic StringPROPERTIES_PRINT_TRANSFER_PREFIXPrefix for JasperReports properties that specify properties to be transferred from report templates to print objects.static StringPROPERTY_BOOKMARKSstatic StringPROPERTY_BOTTOM_MARGINstatic StringPROPERTY_COLLAPSE_MISSING_BOOKMARK_LEVELSstatic StringPROPERTY_CREATE_BOOKMARKSstatic StringPROPERTY_FORMAT_FACTORY_CLASSstatic StringPROPERTY_LEFT_MARGINstatic StringPROPERTY_LOCALE_CODEstatic StringPROPERTY_NAMEstatic StringPROPERTY_ORIENTATIONstatic StringPROPERTY_ORIGINSstatic StringPROPERTY_PAGE_HEIGHTstatic StringPROPERTY_PAGE_WIDTHstatic StringPROPERTY_PAGESstatic StringPROPERTY_PARTSstatic StringPROPERTY_RIGHT_MARGINstatic StringPROPERTY_STYLESstatic StringPROPERTY_TIME_ZONE_IDstatic StringPROPERTY_TOP_MARGIN
-
Constructor Summary
Constructors Modifier Constructor Description JasperPrint()Creates a new empty document.protectedJasperPrint(List<JRPrintPage> pages)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBookmark(PrintBookmark bookmark)Adds a new page to the document.voidaddOrigin(JROrigin origin)Adds a new style to the report origins.voidaddPage(int index, JRPrintPage page)Adds a new page to the document, placing it at the specified index.voidaddPage(JRPrintPage page)Adds a new page to the document.voidaddPart(int pageIndex, PrintPart part)Adds a new part to the document.voidaddStyle(JRStyle style)Adds a new style to the report styles.voidaddStyle(JRStyle style, boolean isIgnoreDuplicate)Adds a new style to the report styles.protected voidcollectAnchors(Collection<JRPrintElement> elements, int pageIndex, int offsetX, int offsetY)voidcopyFrom(JasperPrint jasperPrint)Map<String,JRPrintAnchorIndex>getAnchorIndexes()List<PrintBookmark>getBookmarks()IntegergetBottomMargin()JRStylegetDefaultStyle()Returns the default report style.JRDefaultStyleProvidergetDefaultStyleProvider()When we want to virtualize pages, we want a style provider that is not the print object itself.JRPropertyChangeSupportgetEventSupport()Returns the property change support object for this instance.StringgetFormatFactoryClass()Returns the name of the class implementing theFormatFactoryinterface to use with this document.IntegergetLeftMargin()StringgetLocaleCode()Returns the code of the defaultjava.util.Localeto be used for the elements of this print object.StringgetName()OrientationEnumgetOrientationValue()Returns the page orientation.JROrigin[]getOrigins()Gets an array of report origins.List<JROrigin>getOriginsList()Gets a list of report origins.Map<JROrigin,Integer>getOriginsMap()Gets a map of report origins.PrintPageFormatgetPageFormat()PrintPageFormatgetPageFormat(int pageIndex)intgetPageHeight()List<JRPrintPage>getPages()Returns a list of all pages in the filled report.intgetPageWidth()JRPropertiesHoldergetParentProperties()Returns the parent properties holder, whose properties are used as defaults for this object.PrintPartsgetParts()Returns a list of all parts in the filled report.JRPropertiesMapgetPropertiesMap()Returns this object's properties map.StringgetProperty(String propName)String[]getPropertyNames()IntegergetRightMargin()JRStyle[]getStyles()Gets an array of report styles.List<JRStyle>getStylesList()Gets a list of report styles.Map<String,JRStyle>getStylesMap()Gets a map of report styles.StringgetTimeZoneId()Returns theIDof the defaultjava.util.TimeZoneto be used for the elements of this print object.IntegergetTopMargin()protected booleanhasEventSupport()booleanhasParts()Determines whether this document contains parts.booleanhasProperties()Checks whether the object has any properties.JROriginremoveOrigin(JROrigin origin)JRPrintPageremovePage(int index)Removes a page from the document.PrintPartremovePart(int pageIndex)Removes a part from the document.voidremoveProperty(String propName)JRStyleremoveStyle(String styleName)JRStyleremoveStyle(JRStyle style)voidsetBookmarks(List<PrintBookmark> bookmarks)voidsetBottomMargin(Integer bottomMargin)Sets the bottom page margin.voidsetDefaultStyle(JRStyle style)Sets the default report style.voidsetFormatFactoryClass(String formatFactoryClass)Sets the name of the class implementing theFormatFactoryinterface to use with this document.voidsetJasperReportsContext(JasperReportsContext jasperReportsContext)voidsetLeftMargin(Integer leftMargin)Sets the left page margin.voidsetLocaleCode(String localeCode)Sets the the code of the defaultjava.util.Localeto be used for this object.voidsetName(String name)Sets the name of the document.voidsetOrientation(OrientationEnum orientationValue)Sets the page orientation.voidsetPageHeight(int pageHeight)Sets the page height.voidsetPageWidth(int pageWidth)Sets the page width.voidsetProperty(String propName, String value)voidsetRightMargin(Integer rightMargin)Sets the right page margin.voidsetTimeZoneId(String timeZoneId)Sets the theIDof the defaultjava.util.TimeZoneto be used for this object.voidsetTopMargin(Integer topMargin)Sets the top page margin.
-
-
-
Field Detail
-
EXCEPTION_MESSAGE_KEY_DUPLICATE_STYLE
public static final String EXCEPTION_MESSAGE_KEY_DUPLICATE_STYLE
- See Also:
- Constant Field Values
-
PROPERTIES_PRINT_TRANSFER_PREFIX
public static final String PROPERTIES_PRINT_TRANSFER_PREFIX
Prefix for JasperReports properties that specify properties to be transferred from report templates to print objects.
-
PROPERTY_CREATE_BOOKMARKS
public static final String PROPERTY_CREATE_BOOKMARKS
- See Also:
- Constant Field Values
-
PROPERTY_COLLAPSE_MISSING_BOOKMARK_LEVELS
public static final String PROPERTY_COLLAPSE_MISSING_BOOKMARK_LEVELS
- See Also:
- Constant Field Values
-
PROPERTY_NAME
public static final String PROPERTY_NAME
- See Also:
- Constant Field Values
-
PROPERTY_PAGE_WIDTH
public static final String PROPERTY_PAGE_WIDTH
- See Also:
- Constant Field Values
-
PROPERTY_PAGE_HEIGHT
public static final String PROPERTY_PAGE_HEIGHT
- See Also:
- Constant Field Values
-
PROPERTY_TOP_MARGIN
public static final String PROPERTY_TOP_MARGIN
- See Also:
- Constant Field Values
-
PROPERTY_LEFT_MARGIN
public static final String PROPERTY_LEFT_MARGIN
- See Also:
- Constant Field Values
-
PROPERTY_BOTTOM_MARGIN
public static final String PROPERTY_BOTTOM_MARGIN
- See Also:
- Constant Field Values
-
PROPERTY_RIGHT_MARGIN
public static final String PROPERTY_RIGHT_MARGIN
- See Also:
- Constant Field Values
-
PROPERTY_ORIENTATION
public static final String PROPERTY_ORIENTATION
- See Also:
- Constant Field Values
-
PROPERTY_STYLES
public static final String PROPERTY_STYLES
- See Also:
- Constant Field Values
-
PROPERTY_ORIGINS
public static final String PROPERTY_ORIGINS
- See Also:
- Constant Field Values
-
PROPERTY_PARTS
public static final String PROPERTY_PARTS
- See Also:
- Constant Field Values
-
PROPERTY_PAGES
public static final String PROPERTY_PAGES
- See Also:
- Constant Field Values
-
PROPERTY_BOOKMARKS
public static final String PROPERTY_BOOKMARKS
- See Also:
- Constant Field Values
-
PROPERTY_FORMAT_FACTORY_CLASS
public static final String PROPERTY_FORMAT_FACTORY_CLASS
- See Also:
- Constant Field Values
-
PROPERTY_LOCALE_CODE
public static final String PROPERTY_LOCALE_CODE
- See Also:
- Constant Field Values
-
PROPERTY_TIME_ZONE_ID
public static final String PROPERTY_TIME_ZONE_ID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JasperPrint
public JasperPrint()
Creates a new empty document.
-
JasperPrint
protected JasperPrint(List<JRPrintPage> pages)
-
-
Method Detail
-
setJasperReportsContext
public void setJasperReportsContext(JasperReportsContext jasperReportsContext)
-
getName
public String getName()
- Returns:
- Returns the name of the document
-
setName
public void setName(String name)
Sets the name of the document.- Parameters:
name- name of the document
-
getPageFormat
public PrintPageFormat getPageFormat(int pageIndex)
- Returns:
- Returns the page format for specified page index.
-
getPageFormat
public PrintPageFormat getPageFormat()
-
getPageWidth
public int getPageWidth()
- Returns:
- Returns the page width
-
setPageWidth
public void setPageWidth(int pageWidth)
Sets the page width.- Parameters:
pageWidth- page width
-
getPageHeight
public int getPageHeight()
- Returns:
- Returns the page height.
-
setPageHeight
public void setPageHeight(int pageHeight)
Sets the page height.- Parameters:
pageHeight- page height
-
getTopMargin
public Integer getTopMargin()
- Returns:
- Returns the top page margin
-
setTopMargin
public void setTopMargin(Integer topMargin)
Sets the top page margin.- Parameters:
topMargin- top page margin
-
getLeftMargin
public Integer getLeftMargin()
- Returns:
- Returns the left page margin
-
setLeftMargin
public void setLeftMargin(Integer leftMargin)
Sets the left page margin.- Parameters:
leftMargin- left page margin
-
getBottomMargin
public Integer getBottomMargin()
- Returns:
- Returns the bottom page margin
-
setBottomMargin
public void setBottomMargin(Integer bottomMargin)
Sets the bottom page margin.- Parameters:
bottomMargin- bottom page margin
-
getRightMargin
public Integer getRightMargin()
- Returns:
- Returns the right page margin
-
setRightMargin
public void setRightMargin(Integer rightMargin)
Sets the right page margin.- Parameters:
rightMargin- right page margin
-
getOrientationValue
public OrientationEnum getOrientationValue()
Returns the page orientation.
-
setOrientation
public void setOrientation(OrientationEnum orientationValue)
Sets the page orientation.
-
hasProperties
public boolean hasProperties()
Description copied from interface:JRPropertiesHolderChecks whether the object has any properties.- Specified by:
hasPropertiesin interfaceJRPropertiesHolder- Returns:
- whether the object has any properties
-
getPropertiesMap
public JRPropertiesMap getPropertiesMap()
Description copied from interface:JRPropertiesHolderReturns this object's properties map.- Specified by:
getPropertiesMapin interfaceJRPropertiesHolder- Returns:
- this object's properties map
-
getParentProperties
public JRPropertiesHolder getParentProperties()
Description copied from interface:JRPropertiesHolderReturns the parent properties holder, whose properties are used as defaults for this object.- Specified by:
getParentPropertiesin interfaceJRPropertiesHolder- Returns:
- the parent properties holder, or
nullif no parent
-
getPropertyNames
public String[] getPropertyNames()
-
removeProperty
public void removeProperty(String propName)
-
getDefaultStyle
public JRStyle getDefaultStyle()
Returns the default report style.
-
setDefaultStyle
public void setDefaultStyle(JRStyle style)
Sets the default report style.
-
getDefaultStyleProvider
public JRDefaultStyleProvider getDefaultStyleProvider()
When we want to virtualize pages, we want a style provider that is not the print object itself.
-
getStyles
public JRStyle[] getStyles()
Gets an array of report styles.
-
addStyle
public void addStyle(JRStyle style) throws JRException
Adds a new style to the report styles.- Throws:
JRException
-
addStyle
public void addStyle(JRStyle style, boolean isIgnoreDuplicate) throws JRException
Adds a new style to the report styles.- Throws:
JRException
-
getOrigins
public JROrigin[] getOrigins()
Gets an array of report origins.
-
addOrigin
public void addOrigin(JROrigin origin)
Adds a new style to the report origins.
-
hasParts
public boolean hasParts()
Determines whether this document contains parts.- Returns:
- whether this document contains parts
- See Also:
getParts()
-
getParts
public PrintParts getParts()
Returns a list of all parts in the filled report.
-
addPart
public void addPart(int pageIndex, PrintPart part)Adds a new part to the document.
-
removePart
public PrintPart removePart(int pageIndex)
Removes a part from the document.
-
getPages
public List<JRPrintPage> getPages()
Returns a list of all pages in the filled report.
-
addPage
public void addPage(JRPrintPage page)
Adds a new page to the document.
-
addPage
public void addPage(int index, JRPrintPage page)Adds a new page to the document, placing it at the specified index.
-
removePage
public JRPrintPage removePage(int index)
Removes a page from the document.
-
getBookmarks
public List<PrintBookmark> getBookmarks()
-
addBookmark
public void addBookmark(PrintBookmark bookmark)
Adds a new page to the document.
-
setBookmarks
public void setBookmarks(List<PrintBookmark> bookmarks)
-
getAnchorIndexes
public Map<String,JRPrintAnchorIndex> getAnchorIndexes()
-
collectAnchors
protected void collectAnchors(Collection<JRPrintElement> elements, int pageIndex, int offsetX, int offsetY)
-
getFormatFactoryClass
public String getFormatFactoryClass()
Returns the name of the class implementing theFormatFactoryinterface to use with this document.
-
setFormatFactoryClass
public void setFormatFactoryClass(String formatFactoryClass)
Sets the name of the class implementing theFormatFactoryinterface to use with this document.
-
getLocaleCode
public String getLocaleCode()
Returns the code of the defaultjava.util.Localeto be used for the elements of this print object.When filling a report, the value of the
REPORT_LOCALEparameter (or the default locale if the parameter has no explicit value) is saved using this attribute. Some elements (e.g. elements rendered by a subreport) in the print object can override this default locale.- Returns:
- the code of the default
java.util.Localefor this object - See Also:
JRPrintText.getLocaleCode()
-
setLocaleCode
public void setLocaleCode(String localeCode)
Sets the the code of the defaultjava.util.Localeto be used for this object.- Parameters:
localeCode- the locale code, using thejava.util.Locale.toString()convention.- See Also:
getLocaleCode(),Locale.toString()
-
getTimeZoneId
public String getTimeZoneId()
Returns theIDof the defaultjava.util.TimeZoneto be used for the elements of this print object.When filling a report, the value of the
REPORT_TIME_ZONEparameter (or the default time zine if the parameter has no explicit value) is saved using this attribute. Some elements (e.g. elements rendered by a subreport) in the print object can override this default time zone.- Returns:
- the ID of the default
java.util.TimeZonefor this object - See Also:
JRPrintText.getTimeZoneId()
-
setTimeZoneId
public void setTimeZoneId(String timeZoneId)
Sets the theIDof the defaultjava.util.TimeZoneto be used for this object.- Parameters:
timeZoneId- the time zone ID- See Also:
getTimeZoneId(),TimeZone.getID()
-
copyFrom
public void copyFrom(JasperPrint jasperPrint)
-
hasEventSupport
protected boolean hasEventSupport()
-
getEventSupport
public JRPropertyChangeSupport getEventSupport()
Description copied from interface:JRChangeEventsSupportReturns the property change support object for this instance.- Specified by:
getEventSupportin interfaceJRChangeEventsSupport- Returns:
- the property change support object for this instance
-
-