Question

Does anybody know how to design report in FastReport so that when user changes page orientation all column headers and data autofits new page width? I couldn't find any anchor mechanism there. Maybe I can do that during run-time? But then I need to catch page orientation change event somehow. Can anybody help?

Was it helpful?

Solution

I don't know what the question is: Bands are magnetic to page borders by default, so they fit the new page width.

But if you want the frxMemoview objects to move and resize according to the new page size, you should use the beforeprint event of the report to recalculate and move or size the report components.

If you have a report that can be printed both in portrait or landscape, the easiest way to buid this would be a layout for portrait and one for landscape. You could show a printersetupdailog before loading the report and depending on the orientation load the portrait or landscape layout.

This may not be the cleanest way. Building your report runtime in code is another option and recalculating every component in the report is another. But they involve a lot of coding and what if the user selects "Letter" instead of "A4"?

Regards, Teo FR dealer in Holland.

OTHER TIPS

You can :

  • use the Align property of each TfrxMemoview...
  • make it with Script

Sometimes it is necessary to modify report page settings (for example, to modify paper alignment or size) from a code. The TfrxReportPage class contains the following properties, defining the size of the page:

   property Orientation: TPrinterOrientation default poPortrait;

   property PaperWidth: Extended;

   property PaperHeight: Extended;

   property PaperSize: Integer;

The «PaperSize» property sets paper format. This is one of the standard values, defined in the Windows.pas (for example, DMPAPER_A4). If a value to this property is assigned, FastReport fills the «PaperWidth» and «PaperHeight» properties automatically (paper size in millimeters). Setting the DMPAPER_USER (or 256) value as a format, would mean that custom paper size is set. In this case, the «PaperWidth» and «PaperHeight» properties should be filled manually.

The following example shows, how to modify parameters of the first page (it is assumed that we already have a report):

Pascal:

var
Page: TfrxReportPage; 
{ the first report’s page has [1] index. [0] is the Data page. } 
Page := TfrxReportPage(frxReport1.Pages[1]);  
{ modify the size } 
Page.PaperSize := DMPAPER_A2;   
{ modify the paper orientation }  
Page.Orientation := poLandscape;

C++:

TfrxReportPage * Page;
// the first report’s page has [1] index. [0] is the Data page. 
Page = (TfrxReportPage *)frxReport1.Pages[1];
// modify the size 
Page->PaperSize = DMPAPER_A2;
// modify the paper orientation 
Page->Orientation = poLandscape;

On BeginDoc i you can acess the properties from it using (frxPrincipal.FindObject('Page1') as TfrxReportPage).PaperSize := DMPAPER_A4;

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top