Java Reference
In-Depth Information
After executing the preceding example, a new report, or jrprint file, is saved to disk.
We can view it by using the
JasperViewer
utility included with JasperReports.
The
JasperViewer
utility is discussed in detail in Chapter 3.
In this example, we created the report and immediately saved it to disk. The
JasperFillManager
class also contains methods to send a report to an output
stream, or to store it in memory in the form of a
JasperPrint
object. Storing the
compiled report in a
JasperPrint
object allows us to further manipulate the report.
We could, for example, export it to PDF or another format.
The method used to store a report into a
JasperPrint
object is
JasperFillManager.
fillReport()
. The method used to send the report to an output stream is
JasperFillManager.fillReportToStream()
. These two methods accept the same
parameters as
JasperFillManager.fillReportToFile()
, and are trivial to use
once we are familiar with this method. Refer to the JasperReports API for details.
In the next example, we will fill our report and immediately export it to PDF by
taking advantage of the
net.sf.jasperreports.engine.JasperRunManager.
runReportToPDFStream()
method.