Modifying a  report page’s properties

Top  Previous  Next

Sometimes it is necessary to change report page settings (for example paper alignment or size) in code. The “TfrxReportPage” class contains the following properties which define the size of the page:

 

  property Orientation: TPrinterOrientation default poPortrait;

  property PaperWidth: Extended;

  property PaperHeight: Extended;

  property PaperSize: Integer;

 

The “PaperSize” property sets the paper format. This is one of the standard values defined in Windows.pas (for example DMPAPER_A4). If a value is assigned to this property then FastReport sets the “PaperWidth” and “PaperHeight” properties automatically (paper size in millimeters). Setting “PaperSize” to DMPAPER_USER (or to 256) means that a custom paper size is set. In this case the “PaperWidth” and “PaperHeight” properties will need to be be set in code.

 

The following example shows how to change the properties of the first page, assuming we already have a report:

 

Pascal:

 

var

 Page: TfrxReportPage;

 

{ first report page has index [1] : index [0] is the Data page }

Page := TfrxReportPage(frxReport1.Pages[1]);

{ change size }

Page.PaperSize := DMPAPER_A2;

{ change  paper orientation }

Page.Orientation := poLandscape;

 

C++:

 

TfrxReportPage * Page;

 

// first report page has index [1] : index [0] is the Data page

Page = (TfrxReportPage *)frxReport1.Pages[1];

// change size

Page->PaperSize = DMPAPER_A2;

// change paper orientation

Page->Orientation = poLandscape;