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:
  • Field Details

  • Constructor Details

    • JasperPrint

      public JasperPrint()
      Creates a new empty document.
    • JasperPrint

      protected JasperPrint(List<JRPrintPage> pages)
  • Method Details

    • 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
    • getOrientation

      public OrientationEnum getOrientation()
      Returns the page orientation.
      See Also:
    • setOrientation

      public void setOrientation(OrientationEnum orientation)
      Sets the page orientation.
      See Also:
    • hasProperties

      public boolean hasProperties()
      Description copied from interface: JRPropertiesHolder
      Checks whether the object has any properties.
      Specified by:
      hasProperties in interface JRPropertiesHolder
      Returns:
      whether the object has any properties
    • getPropertiesMap

      public JRPropertiesMap getPropertiesMap()
      Description copied from interface: JRPropertiesHolder
      Returns this object's properties map.
      Specified by:
      getPropertiesMap in interface JRPropertiesHolder
      Returns:
      this object's properties map
    • getParentProperties

      public JRPropertiesHolder getParentProperties()
      Description copied from interface: JRPropertiesHolder
      Returns the parent properties holder, whose properties are used as defaults for this object.
      Specified by:
      getParentProperties in interface JRPropertiesHolder
      Returns:
      the parent properties holder, or null if no parent
    • getPropertyNames

      public String[] getPropertyNames()
    • getProperty

      public String getProperty(String propName)
    • setProperty

      public void setProperty(String propName, String value)
    • 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.
    • getStylesList

      public List<JRStyle> getStylesList()
      Gets a list of report styles.
    • getStylesMap

      public Map<String,JRStyle> getStylesMap()
      Gets a map 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
    • removeStyle

      public JRStyle removeStyle(String styleName)
    • removeStyle

      public JRStyle removeStyle(JRStyle style)
    • getOrigins

      public JROrigin[] getOrigins()
      Gets an array of report origins.
    • getOriginsList

      public List<JROrigin> getOriginsList()
      Gets a list of report origins.
    • getOriginsMap

      public Map<JROrigin,Integer> getOriginsMap()
      Gets a map of report origins.
    • addOrigin

      public void addOrigin(JROrigin origin)
      Adds a new style to the report origins.
    • removeOrigin

      public JROrigin removeOrigin(JROrigin origin)
    • hasParts

      public boolean hasParts()
      Determines whether this document contains parts.
      Returns:
      whether this document contains parts
      See Also:
    • 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 the FormatFactory interface to use with this document.
    • setFormatFactoryClass

      public void setFormatFactoryClass(String formatFactoryClass)
      Sets the name of the class implementing the FormatFactory interface to use with this document.
    • getLocaleCode

      public String getLocaleCode()
      Returns the code of the default java.util.Locale to be used for the elements of this print object.

      When filling a report, the value of the REPORT_LOCALE parameter (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.Locale for this object
      See Also:
    • setLocaleCode

      public void setLocaleCode(String localeCode)
      Sets the the code of the default java.util.Locale to be used for this object.
      Parameters:
      localeCode - the locale code, using the java.util.Locale.toString() convention.
      See Also:
    • getTimeZoneId

      public String getTimeZoneId()
      Returns the ID of the default java.util.TimeZone to be used for the elements of this print object.

      When filling a report, the value of the REPORT_TIME_ZONE parameter (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.TimeZone for this object
      See Also:
    • setTimeZoneId

      public void setTimeZoneId(String timeZoneId)
      Sets the the ID of the default java.util.TimeZone to be used for this object.
      Parameters:
      timeZoneId - the time zone ID
      See Also:
    • copyFrom

      public void copyFrom(JasperPrint jasperPrint)
    • hasEventSupport

      protected boolean hasEventSupport()
    • getEventSupport

      public JRPropertyChangeSupport getEventSupport()
      Description copied from interface: JRChangeEventsSupport
      Returns the property change support object for this instance.
      Specified by:
      getEventSupport in interface JRChangeEventsSupport
      Returns:
      the property change support object for this instance