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

Detect last page in OnPageEnd event

edited May 2006 in General
Hi,

I need to manually add drawcomands at the exact position of the last printed
band (whatever which band it is) on every page except the last page. I'm
using the TppReport.Engine.OnPageEnd event to achieve this. To find out the
exact bottom position of the last printed band on a page I use the
TppReport.Engine.PrintPosRect property. To detect the last page i use the
TppReport.Engine.Page.LastPage property but its value is always False. Even
if i change the report to psTwoPass PassSetting. What's wrong? Is there a
better way to add drawcomands at the exact position of the last printed
bandon every page except the last page?

Greetings,
Filip Moons

procedure TDEP33010F.FormCreate(Sender: TObject);
begin
...
MyReport.Engine.OnPageEnd := EndOfPage;
....
end;


procedure TDEP33010F.EndOfPage(Sender: TObject);
var
ALine: TppDrawLine;
begin
if not(MyReport.Engine.Page.LastPage) then
begin
// Horizontale lijn
ALine := TppDrawLine.Create(Self);
ALine.Page := MyReport.Engine.Page;
ALine.LinePosition := ppLine_HDR_H_1.Position;
ALine.Weight := ppLine_HDR_H_1.Weight;
ALine.Height := ppLine_HDR_H_1.mmHeight;
ALine.Top :=
MyReport.Engine.PrintPosRect.Top-ppLine_HDR_H_1.mmHeight;
ALine.Left := MyReport.PrinterSetup.PageDef.mmMarginLeft +
ppLine_HDR_H_1.mmLeft;
ALine.Width := ppLine_HDR_H_1.mmWidth;
end;
end; {EndOfPage}

Comments

  • edited May 2006
    Hi Filip,

    1. Be sure you are using a two pass report. This is necessary in order for
    the report engine to determine which page is the last page.

    2. Try using the OnStartPage event to check for the last page. I believe
    the OnEndPage event fires too late to check this property value.

    --
    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.