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

PageCount problem

edited March 2007 in General
Hi,



I have to develop a PageCounter component. I have to determine the amount of
all pages. Band.Report.PageCount gives me the amount of generated pages, but
not the all pages in the report. When I click on "Last Page" button on
Preview window, the result will be correct of course, because all the pages
has been generated.



How can I determine the amount of pages without generating all pages?



My source code:



function TppPageCounter.GetTheText: string;

var

PC, PN: Integer;

begin

if Assigned(OnGetText) then

OnGetText(Self, Result)

else

begin

if Printing then

begin

PC:= Band.Report.PageCount; //Warning: not a valid amount, based on
generated pages

PN:= Band.Report.PageNo;

end

else { design mode }

begin

PC:= 1;

PN:= 1;

end;

...

end;

end;





Regards,



Robert

Comments

  • edited March 2007
    Hi Robert,

    ReportBuilder has no way of knowing how many pages will be generated unless
    it measures the space needed to generate the report before it displays or
    prints. This can be done by setting the Report.PassSetting to psTwoPass.

    Once you set the report to TwoPass, you simply need to check that the
    Report.SecondPass property is true and the page count will be the correct
    number.

    Note: If you are inside a group the Report.PageCount will represent the
    number of pages in that group. Use Report.AbsolutePageCount for the number
    of pages in the entire report.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.