Output as HTML (Java)

Set up and configure output to HTML from your reporting application.

To use any of the renderer classes, you must import the com.fourjs.report.runtime package:
import com.fourjs.report.runtime.*;

Example

This code snippet uses the HTMLRenderer class:
// code snippet starts

String designFile = "OrderReport.4rp";
String outputFilename = "SalesList.html";
    
FormatHandler handler = new FormatWriter(outputFilename);
HTMLRenderer renderer = new HTMLRenderer(handler);
renderer.setIgnoreColumnAlignment(true);
renderer.setEmbedImages(true);
FourRpLayouter report = new FourRpLayouter(designFile, renderer);

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

// some code omitted - view full source in demo

report.runFromJAXBObject(data);
    
// open the file
File result = new File(outputFilename);
Desktop desktop = Desktop.getDesktop();
desktop.open(result);

// code snippet ends
In this example:
  • A FormatHandler object named handler is defined using the FormatWriter class, taking the name of the output file as its input.
  • An object named renderer is defined using the HTMLRenderer class, taking handler as input.
  • The setIgnoreColumnAlignment method is set to true, allowing column alignment of items to be ignored for a more compact representation.
  • The setEmbedImages method activates image embedding in the report document.
  • FourRpLayouter report = new FourRpLayouter(designFile, renderer) creates the FourRpLayouter object for the specified report file that outputs a HTML file with the provided name.

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