Question
“How can I draw a horizontal line after the last detail band on each page?”
Solution
The solution is to use the DetailBand AfterPrint event to track the page position and then use the Report EndPage event to add a DrawComamnd to the Page.
Download: LastDynamicDetailLine.zip
Sample Delphi code:
uses
ppTypes,
ppUtils,
ppDrwCmd;
procedure TForm1.ppReport1StartPage(Sender: TObject);
begin
// initialize for start of page
FPosDetailBottom := -1;
end;
procedure TForm1.ppDetailBand1AfterPrint(Sender: TObject);
begin
// update print position
FPosDetailBottom := ppReport1.Engine.PrintPosRect.Top;
end;
procedure TForm1.ppReport1EndPage(Sender: TObject);
var
lDrawLine: TppDrawLine;
begin
if (FPosDetailBottom <> -1) then
begin
// add DrawCommand to Page
lDrawLine := TppDrawLine.Create(nil);
lDrawLine.Page := ppReport1.Engine.Page;
lDrawLine.LinePosition := lpTop;
lDrawLine.Left := ppReport1.PrinterSetup.PageDef.mmMarginLeft;
lDrawLine.Width := ppReport1.PrinterSetup.PageDef.mmPrintableWidth;
lDrawLine.Top := FPosDetailBottom;
end;
end;