Feeding input/output stream to JReport Engine

By feeding input/output stream instead of files to JReport Engine, you can control the input/output stream via the stream API directly.

The stream API consists of two types of function APIs:

Input stream API

Input stream API provides a programmable way to specify data for JReport products besides the URI.

For supporting input stream API, the following requirements should be met:

An interface Jet.datasource.InputStreamFactory is provided in the Engine Bean for you to implement so that JReport Engine can create your customized InputStream instance from your InputStreamFactory implementation. The following is the method in the interface:

Except for implementing the InputStreamFactory interface, you need also call either of the two methods in order to use input stream:

Reference: See the demo XmlStreamSample.java for input stream API usage in <install_root>\help\designer\samples.

Output stream API

Output stream API enables exporting current report and specified result file as output stream in common file formats, such as PDF, RTF, Excel, Text, and PostScript.

You can use output stream API as follows:

... ... JREngine bean = new JREngine(); 
bean.setReportHome(ReportHome); 
... ...//initialize bean 
OutputStream output=new FileOutputStream("filename"); 
... ...//initialize outputstream 
bean.exportToPdf(output); ... ...