2010-09-01 64 views

回答

1

首先准备文档,因此系统本身知道将生成多少页面。你可以使用一个系统变量(手边没有QR来告诉你确切的名字)。

例如:

procedure TForm1.Click(Sender: TObject); 
begin 
    //this actually run the report in memory to 
    //calculate things like total page count 
    Report1.Prepare; 
    Report1.Print; //or PreviewModal; 
end; 
0

解决方案是在预览过程中统计页数,因此当您将其发送到打印机时,您可以将其放置在页脚中。

6
procedure TForm1.Button1Click(Sender: TObject); 
begin 
    Form2.QuickRep1.Prepare; 
    Form2.QuickRep1.FTotalPages := Form2.QuickRep1.QRPRinter.PageCount; 
    Form2.QuickRep1.QRPrinter.Free; 
    Form2.QuickRep1.QuickRep1.QRPrinter := nil; 
    Form2.QuickRep1.PreviewModal; // or .Print 
end; 

FTotalPages在窗体2保持所述TQuickRep部件声明。

public 
    { Public declarations } 
    FTotalPages: Integer; 

注意,QRPrinter对象必须经过释放准备和PreviewModal(或.PRINT)事情之前,你会得到一个内存泄漏。

在窗体2,在Quickreport1,放置QRLabel,并实现它的onPrint事件处理

procedure TForm2.QRLabel1Print(sender: TObject; var Value: string); 
begin 
    Value := 'Page: ' + IntToStr(QuickRep1.QRPrinter.PageNumber) + ' of ' + IntToStr(FTotalPages); 
end;