FPReport: bug when group footer starts on new page
Summary
When a group footer starts on top of a new page, the aggregates are shown as zero. If the group footer is not the first band on a new page, it goes well.
System Information
- Operating system: Arch Linux (should be OS independent)
- Processor architecture: x86-64
- Compiler version: Lazarus 4.99 (rev main_4_99-1036-g37bb0cb225) FPC 3.3.1 x86_64-linux-gtk2
- Device: Laptop
Steps to reproduce
Compile and run the example project below.
- If the data bands and group footer fit on one page, all goes well.
- If the data bands do not fit on one page and continue on the next, all goes well.
- If the data bands fit on one page, but there is insufficient space left for the group footer, the group footer is placed as first band on the next page. In this specific case, the aggregates are zero.
Example Project
program project1;
{$mode objfpc}{$H+}
uses Classes, SysUtils, fpreport, fpreportjson, fpreportpdfexport, fpttf, jsonparser, dynlibs;
const
JSONDATA =
'[ ' + LineEnding +
' { "group": "Alpha", "name": "Alpha 1", "amount": 5 },' + LineEnding +
' { "group": "Alpha", "name": "Alpha 2", "amount": 5 },' + LineEnding +
' { "group": "Alpha", "name": "Alpha 3", "amount": 5 },' + LineEnding +
' { "group": "Alpha", "name": "Alpha 4", "amount": 5 },' + LineEnding +
' { "group": "Alpha", "name": "Alpha 5", "amount": 5 },' + LineEnding +
' { "group": "Alpha", "name": "Alpha 6", "amount": 5 },' + LineEnding +
' { "group": "Beta", "name": "Beta 1", "amount": 5 }, ' + LineEnding +
' { "group": "Beta", "name": "Beta 2", "amount": 5 }, ' + LineEnding +
' { "group": "Beta", "name": "Beta 3", "amount": 5 }, ' + LineEnding +
' { "group": "Beta", "name": "Beta 4", "amount": 5 }, ' + LineEnding +
' { "group": "Beta", "name": "Beta 5", "amount": 5 }, ' + LineEnding +
' { "group": "Beta", "name": "Beta 6", "amount": 5 }, ' + LineEnding +
' { "group": "Gamma", "name": "Gamma 1", "amount": 5 },' + LineEnding +
' { "group": "Gamma", "name": "Gamma 2", "amount": 5 } ' + LineEnding +
'] ';
procedure Test;
var
rep: TFPReport;
page: TFPReportPage;
databand: TFPReportDataBand;
gheader: TFPReportGroupHeaderBand;
gfooter: TFPReportGroupFooterBand;
data: TFPReportJSONData;
exp: TFPReportExportPDF;
begin
PaperManager.RegisterStandardSizes;
gTTFontCache.ReadStandardFonts;
rep := TFPReport.Create(nil);
page := TFPReportPage.Create(rep);
page.PageSize.PaperName := 'A4';
data := TFPReportJSONData.Create(page);
page.Data := data;
data.JSON := JSONDATA;
gheader := TFPReportGroupHeaderBand.Create(page);
gheader.GroupCondition := 'group';
gheader.Layout.Height := 20;
gheader.Frame.Shape := fsRectangle;
gheader.Frame.BackgroundColor := $cccccc;
with TFPReportMemo.Create(gheader) do
begin
Layout.SetPosition(10, 10, 100, 10);
Text := 'Group: [group]';
end;
databand := TFPReportDataBand.Create(page);
databand.Data := data;
databand.Layout.Height := 45;
databand.Frame.Color := clBlack;
databand.Frame.Shape := fsRectangle;
with TFPReportMemo.Create(databand) do
begin
Layout.SetPosition(10, 10, 100, 30);
Text := 'Name: [name]; Amount: [amount]';
end;
gfooter := TFPReportGroupFooterBand.Create(page);
gfooter.GroupHeader := gheader;
gfooter.Layout.Height := 20;
gfooter.Frame.Shape := fsRectangle;
gfooter.Frame.BackgroundColor := $eeeeee;
with TFPReportMemo.Create(gfooter) do
begin
Layout.SetPosition(10, 10, 100, 10);
Text := 'Sum of amount: [sum(amount)]';
end;
rep.RunReport;
exp := TFPReportExportPDF.Create(nil);
exp.SetFileName('test.pdf');
rep.RenderReport(exp);
exp.Free;
data.Free;
rep.Free;
end;
begin
Test;
end.
What is the current bug behavior?
See
What is the expected (correct) behavior?
Relevant logs and/or screenshots
See the attached test.pdf to show the output of the test program above. For group Alpha, the group footer starts at the top of page 2 and shows a sum of 0 (zero). For group Beta, the group footer is not the first band of the page and shows the correct value. test.pdf
