Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

RB10.06 D6 Number of Pages printed

edited August 2008 in General
Hi

I am printing a report to pdf via code.

This all works fine but I need to know how many pages were produced in the
pdf. Is there a property I can use from TrsClientReport or TppProducer?

Sorry if it is a bit basic but I can't find the solution through the help or
examples.

regards
Andrew

Comments

  • edited August 2008
    Hi Andrew,

    The easiest way is to implement the OnPageReceive event of the file device
    to keep a running total of the amount of pages generated. You can use the
    ClientReport.BeforePrint event to access the Report.FileDevice object and
    assign the event handler. Below is the signature of the OnPageReceive
    event.

    TppPageEvent = procedure (Sender: TObject; aPage: TObject) of object;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2008
    Nico

    Thanks for your help.

    I did the following

    Private
    procedure OnPageReceive(Sender: TObject; aPage: TObject);
    ..
    ..
    ..
    procedure TdatMain.OnPageReceive(Sender, aPage: TObject);
    begin
    inc(FLastPage);
    end;

    procedure TdatMain.clrMainBeforePrint(Sender: TObject);
    begin
    // Assign the onPageReceieve event to our
    // procedure to count the number of pages
    clrMain.FileDevice.OnPageReceive := OnPageReceive;
    end;

    It worked a treat.

    regards
    Andrew

This discussion has been closed.