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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
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; |