Change paper and page settings with .NET APIs

The default paper settings for a report are specified in the .4rp file. Override the defaults in your report program with the .NET APIs.

Each report design document includes details about the page orientation, the page size of the report, and the report margins. These values are set when a report is first created, and can be altered by the report designer. See Specify the paper settings of a report for details about setting these values within the report design document (.4rp).

In the .NET report application, you can override these report page and paper settings, thanks to the order of precedence for paper settings:

Paper Settings order of precedence

There are three areas which determine the paper settings for a report, listed here in the order of precedence:
  1. In the report application using reporting APIs.
  2. In the report design document (.4rp).
  3. GRW default values.

Change the page height and width

The initial page height is specified in the report design document (.4rp). In the report application, use the .NET APIs to modify the page height for FourRpLayouter or PXMLLayouter objects.
PXMLConsumer layout = new PXMLLayouter(renderer);

// Set the page length (height) and width
layout.pageLength = "6inch";
layout.pageWidth = "8.5inch";
Tip: See Paper Format Abbreviations for possible input values for these methods.

Change the report margins

The initial page margins are specified in the report design document (.4rp). In the report application, use the .NET APIs to modify the page margins for FourRpLayouter or PXMLLayouter objects.
PXMLConsumer layout = new PXMLLayouter(renderer);

layout.topMargin = "15mm";
layout.bottomMargin = "5mm";
layout.leftMargin = "4mm";
layout.rightMargin = "4mm";
Tip: See Paper Format Abbreviations for possible input values for these methods.

Set page orientation

The initial report size is set in the report design document (.4rp). In the report application, use the .NET APIs to change the orientation for FourRpLayouter or PXMLLayouter objects. There is no method for changing the page orientation; you change the height and width of the paper to create a portrait or landscape orientation.

In this example, assume the initial report is a standard A4 portrait report. To change it to an A4 landscape report, use the pageLength() and pageWidth() methods.

PXMLConsumer layout = new PXMLLayouter(renderer);

// Change page orientation
layout.pageLength = "a4width"; // length is now width
layout.pageWidth = "a4length"; // width is now length
Tip: See Paper Format Abbreviations for possible input values for these methods.
Note: Changing page orientation from within the program works best when a report design is based on dynamic layouting.