Question
“How do I ensure that the group footer will display on every page of my report?”
Solution
This can be helpful if you need a page summary band, similar to the page footer band but snaps to the last detail band.
Use the DetailBand.BeforePrint event to determine if the group will break before space runs out on the page. If not, manually add the group drawcommands below the last detail line leaving enough space to print. This will ensure that the group footer prints on every page similar to the Group Header.
Download: GroupFooterOnEveryPage.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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
procedure TForm1.ppDetailBand1BeforePrint(Sender: TObject); var lbGroupBreak: Boolean; begin if FDrewGroupFooter then ppDetailBand1.OutofSpace := True; {peek at next record to determine if group is going to break on this page} lbGroupBreak := WillGroupBreak; if lbGroupBreak then begin //See the included example of an implementation of this routine. DrawGroupFooter(ppReport1.Engine.PrintPosRect.Top); FDrewGroupFooter := True; end; end; function TForm1.WillGroupBreak: Boolean; begin Result := CheckNormalGroupBreak; if not(Result) then Result := CheckSpaceLeftOnPageForGroup; end; {@TForm1.CheckNormalGroupBreak Check to see if normal group breaking will work the standard way of group breaking} function TForm1.CheckNormalGroupBreak: Boolean; var lsCurrentValue: String; lsNextValue: String; begin Result := False; lsCurrentValue := ppReport1.DataPipeline['CustNo']; ppReport1.DataPipeline.Next; if not(ppReport1.Datapipeline.EOF) then begin lsNextValue := ppReport1.Datapipeline['CustNo']; ppReport1.DatapipeLine.Prior; lsCurrentValue := Lowercase(lsCurrentValue); lsNextValue := Lowercase(lsNextValue); if (lsCurrentValue <> lsNextValue) then Result := True; end; end; {@TForm1.CheckSpaceLeftOnPageForGroup If normal group breaking will not force a group break because the group has more records then need to check if have space to print the next record and also the group footer on the page.} function TForm1.CheckSpaceLeftOnPageForGroup: Boolean; var ldRequiredDetailGroupFooterSpaceInInches: Double; ldAvailableSpaceInInches: Double; liAvailableSpace: Integer; begin Result := False; liAvailableSpace := ppReport1.PrinterSetup.PageDef.mmPrintableHeight - ppReport1.Engine.PrintPosRect.Top; ldAvailableSpaceInInches := ppFromMMTHousandths(liAvailableSpace, utInches, pprtVertical, ppReport1.Printer); ldAvailableSpaceInInches := ldAvailableSpaceInInches - ppFooterband1.Height; ldRequiredDetailGroupFooterSpaceInInches := ppDetailBand1.Height + ppGroupFooterband1.Height; if (ldRequiredDetailGroupFooterSpaceInInches > ldAvailableSpaceInInches) then Result := True; end; |