Question
“How can I fill the remaining space of a page with lines after the last detail has printed?”
Solution
- Use a group to keep track of the position of the last detail band on a page. The GroupFooterBand.AfterPrint event can be used to mark the position.
- The Report.OnEndPage event can then be used to manually add line drawcommands to the page from the marked position to the bottom.
Download: FillPageWithLines.zip
Sample Delphi code:
uses
ppDrwCmd;
procedure TForm1.ppGroupFooterBand1AfterPrint(Sender: TObject);
begin
//find the current position after the group footer prints.
FCurrentPosition := ppReport1.Engine.PrintPosRect.Top;
end;
procedure TForm1.ppReport1EndPage(Sender: TObject);
var
lDrawLine: TppDrawLine;
liTop: Integer;
liLineTop: Integer;
liBottom: Integer;
begin
if (FCurrentPosition <> -1) then
begin
liTop := FCurrentPosition;
liBottom := ppReport1.Engine.PageBottom;
liLineTop := liBottom;
//Add a new line until space runs out on the page.
while liTop < liLineTop do
begin
lDrawLine := TppDrawLine.Create(nil);
lDrawLine.Page := ppReport1.Engine.Page;
lDrawLine.Left := ppReport1.PrinterSetup.PageDef.mmMarginLeft;
lDrawLine.Top := liLineTop;
lDrawLine.Width := ppReport1.PrinterSetup.PageDef.mmPrintableWidth;
{change 9075 to change the space between lines}
liLineTop := liLineTop - 9075;
end;
end;
end;