Q1:
How can I determine the number of pages in my report before I preview or print it?
A1:
If you call the report's Prepare method, it will generate the report without
printing or previewing it. After Prepare has finished, the pagecount will be
in the report's qrprinter.pagecount property. Please refer to the manual topic
on Prepare for more information.
Example:
QuickRep1.Prepare;
QuickRep1.ReportTitle := 'This report has ' +
IntToStr(QuickRep1.QRPrinter.PageCount) + ' pages';
QuickRep1.QRPrinter.Free;
QuickRep1.QRPrinter := nil;
QuickRep1.Preview;
==========================================
Q:
We've a problem with QRPrinter.PageCount. We've created our own Previewform
and when we call QRPrinter.PageCount we always get 0. What's wrong??
A:
You need to specify the preview's qrprinter, otherwise the global qrprinter will
be used. Also, the total page count is not known when the preview is first shown,
you must use the preview's OnPageAvailable to update the page count as each page
is rendered.
Example:
procedure TfrmPreview.QRPreviewPageAvailable(Sender: TObject;
PageNum: Integer);
begin
if PageNum = 1 then
Caption := QRPreview.QRPrinter.Title + ' - 1 page'
else
Caption := QRPreview.QRPrinter.Title + ' - ' + IntToStr(PageNum) + ' pages';
case QRPreview.QRPrinter.Status of
mpReady: Caption := Caption + ' READY';
mpBusy: Caption := Caption + ' BUSY';
mpFinished: Caption := Caption + ' FINISHED';
end;
end;