NizamUlMulk
NizamUlMulk

Reputation: 386

How execute a TQuickRep (quickreport) without displaying or printing it?

I need run a report (TQuickRep) for export only, without printing or showing. The Prepare method does nothing. The beforeprints or afterprints events doesn´t fires.

Ex.

var rep: TMyQuickRep; //TMyQuickRep is a report TQuickRep
begin
  rep := TMyQuickRep.Create(Self);
  try
    rep.SomeData := somedata;
    rep.DataSet  := somDataSet;
    rep.Prepare;
    //rep.Run? there isn´t a method for run
    rep.ExportToFilter(TQRPDFDocumentFilter.Create('c:\temp\myreport.pdf'));  
    //pdf is an empty page
  finally
    FreeAndNil(rep);
  end;
end;

Upvotes: 1

Views: 2510

Answers (2)

Dżyszla
Dżyszla

Reputation: 79

After you call Prepare, there are QRPrinter created. This is a container for generated metafiles in fact. Then You can call Export on QRPrinter (not on QR). Don't miss free QRPrinter after export.

Upvotes: 0

L. Piotrowski
L. Piotrowski

Reputation: 1579

This should work for you...( I was looking for a solution just like this and the code below worked for me.)

rep.ExportToFilter(TQRPDFDocumentFilter.Create('c:\temp\myreport.pdf')); 
rep.Print;

Upvotes: 1

Related Questions