Output to a printer (Java)

Set up and configure output to a printer from your reporting application. The report is printed silently, without prompting the user. Only server-side printing is supported.

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 to a printer, use the class Printer to select a printer by name and configure it for printing the report.

Example - Using a server printer

This code sample uses the Printer class:
// code snippet starts

String designFile = "OrderReport.4rp";

Printer printer = new Printer();
printer.setPrinterName("diablo");
   
//Configuring the print output:
printer.add(Sides.TWO_SIDED_LONG_EDGE);
printer.add(new PageRanges(1,2));
printer.add(OrientationRequested.REVERSE_PORTRAIT);
printer.add(new Copies(2));

FourRpLayouter report = new FourRpLayouter(designFile, printer);

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

// some code omitted - view full source in demo

report.runFromJAXBObject(data);
        
// code snippet ends
In this example:
  • A printer object is defined using the Printer class.
  • The setPrinterName method specifies the name of the printer.
  • The add method configures the print output in a series of calls.
  • FourRpLayouter report = new FourRpLayouter(designFile, printer) creates the FourRpLayouter object for the specified report file that outputs to the given printer.

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