Output as Rich Text Format (Java)

Set up and configure output to Rich Text Format (RTF) from your reporting application. This option is useful if you want to edit your report after output.

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 RTFRenderer class:
// code snippet starts

String designFile;
String outputFilename = "SalesList.rtf";
    
if (args.length == 0) {
    designFile = "SalesList.4rp";
} else {
    designFile = args[0];
}

FormatHandler handler = new FormatWriter(outputFilename);
RTFRenderer renderer = new RTFRenderer(handler);
FourRpLayouter report = new FourRpLayouter(designFile, renderer);

report.setDebugLevel(9);
Sales data = new Sales("Columbus Arts", 75038, new Date());

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 RTFRenderer class, taking handler as input.
  • FourRpLayouter report = new FourRpLayouter(designFile, renderer) creates the FourRpLayouter object for the specified report file that outputs an RTF file with the provided name.

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