Take the 2-minute tour ×

I'm using QuickReports within my application and would like to have "Page x of x" within the footer. What's the best way to do this?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

First prepare the document, so the system itselfs know how many pages will produce. There's a system variable you can use (no QR at hand to tell you the exact name).

For example:

procedure TForm1.Click(Sender: TObject);
  //this actually run the report in memory to 
  //calculate things like total page count
  Report1.Print;  //or PreviewModal;
share|improve this answer
procedure TForm1.Button1Click(Sender: TObject);
  Form2.QuickRep1.FTotalPages := Form2.QuickRep1.QRPRinter.PageCount;
  Form2.QuickRep1.QuickRep1.QRPrinter := nil;
  Form2.QuickRep1.PreviewModal; // or .Print

FTotalPages is declared in Form2 that holds the TQuickRep component.

    { Public declarations }
    FTotalPages: Integer;

Note that the QRPrinter object must be freed after Prepare and before PreviewModal (or .Print) else you will get a memory leak.

In Form2, on the Quickreport1, place a QRLabel, and implement it's onPrint event handler

procedure TForm2.QRLabel1Print(sender: TObject; var Value: string);
  Value := 'Page: ' + IntToStr(QuickRep1.QRPrinter.PageNumber) + ' of ' + IntToStr(FTotalPages);
share|improve this answer

A solution is to count the number of pages during preview so when you send it to the printer you can place it in the footer.

share|improve this answer

Your Answer


