Output as Image (Java)

Set up and configure output to image files from your reporting application. This option is useful for archiving.

To use any of the renderer classes, you must import the com.fourjs.report.runtime package:
import com.fourjs.report.runtime.*;
To output your report as an image, use the class ImageRenderer.
Note:

A FormatHandler object is not required for ImageRenderer.

Example

This code snippet shows some of the methods available for an object of the ImageRenderer class:

// code snippet starts

String designFile = "OrderReport.4rp";

ImageRenderer renderer = new ImageRenderer();

//Configuring the Image output:
renderer.setFileType("png");
renderer.setFileNamePrefix("my_image_");
renderer.setFromPage(1);
renderer.setToPage(3);

FourRpLayouter report = new FourRpLayouter(designFile, renderer);

//Run the report 
report.setDebugLevel(9);

// some code omitted - view full source in demo

report.runFromJAXBObject(data);

// code snippet ends
In this example:
  • An object named renderer is defined using the ImageRenderer class.
  • The setFileType method sets the output format. In this example, the files created are .png image files.
  • The setFromPage method sets the first page to be included and the setToPage method sets the last page to be included in the output. In this example, three pages of the report will be printed, starting with page 1 and ending with page 3. An image file will be created for each page.
  • The setFileNamePrefix method sets the prefix for the image files created. In this example, the name of an image file will start with " my_image_", followed by a sequential number: my_image_0001.png, my_image_0002.png, and my_image_0003.png.
  • FourRpLayouter report = new FourRpLayouter(designFile, renderer) creates the FourRpLayouter object for the specified report file that outputs to the given consumer object.

For the full list of methods for this renderer class, refer to the Genero Report Writer Java API documentation.