Create multi-page ISO reports

For reports printed on ISO and JIS-sized pages, you can configure the output to print several logical pages per physical page.

The MultiPageMapper class renders several pages of a report on a single physical page.

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 methods from the MultiPageMapper class:
// start code snippet

String designFile = "OrderReport.4rp";
String outputFilename = "PDFoutput.pdf";

FormatHandler handler = new FormatWriter(outputFilename);
PDFRenderer renderer = new PDFRenderer(handler);

//Defining the Multipage
PXMLConsumer multiPageLayout = new PXMLLayouter(renderer);
MultiPageMapper myMultiPageMapper = new MultiPageMapper(multiPageLayout);
myMultiPageMapper.setIsoNumber(4);
myMultiPageMapper.setPageExponent(2);
myMultiPageMapper.setPortrait(true);
myMultiPageMapper.setPaperLeftMargin("2mm");
myMultiPageMapper.setPaperRightMargin("2mm");
myMultiPageMapper.setPaperTopMargin("2mm");
myMultiPageMapper.setPaperBottomMargin("2mm");
multiPageLayout = myMultiPageMapper;

FourRpProcessor report = new FourRpProcessor(designFile, multiPageLayout);

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

// some code omitted - view full source in demo

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

// stop code snippet
The MultiPageMapper class is used to specify how many logical pages are placed on a physical page, as well as page sizing issues.
Note: For MultiPageMapper, you must use the FourRpProcessor; you cannot use the shortcut.
  • The setIsoNumber method specifies the ISO value of the physical page. In our example, 4 specifies an A4 ISO page size.
  • The setPageExponent method specifies the number of logical pages to place on the physical page, as an index of 2. In our example, myMultiPageMapper.setPageExponent(2) specifies that 2*2 report pages, or 4 logical pages, will print on each physical page. If myMultiPageMapper.setPageExponent(3) is specified, then 2*2*2 report pages, or 8 logical pages, would be printed on each physical page.
  • The setPortrait method sets the orientation of the logical pages of the report. When set to true, the logical pages are portrait.
  • The setPaperLeftMargin, setPaperRightMargin, setPaperTopMargin and setPaperBottomMargin methods set the margins for the physical page. In this example, the margins are set for 2mm on all sides.

Once the MultiPageMapper object is defined, it is used to set the value for the PXMLConsumer object, which then becomes the input for the FourRpProcessor.

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