Dynamic footer questions
Hi,
I am trying to create a dynamic footer band in ReportBuilder 11.06 w/ Delphi
2007.
I need this because I have 3 types of footers, which are dynamic in height
and must be aligned to bottom.
- 2 footers should only print on the first page
- 1 should print on every page
- 1 should only print on the last page
The detailband contains a subreport that could get large (so I do not loop
through details in the mainreport).
So far I have managed to come up with the code below, placed in the
OnStartPage command. This creates the following problem (but only
sometimes):
- Report generates and calculates all bands.
- It detects that footer + detail band cannot fit on the last page and
breaks the detail to the next page.
- At this moment, the lastpage footer is also moved to the last page,
freeing up space on the second to last page and thus preventing the break.
This keeps going over and over again leading to a report that generates an
endless amount of pages when printing (preview seems to be OK), printing the
last page and page before over and over again.
Almost forgot to mention, the report is a 2-pass report.
Does anyone have any idea how to prevent this?
Roald van Doorn
procedure ReportOnStartPage;
var
localMemo : TppCustomMemo;
totalHeight : Double;
begin
{pre-reqs}
totalHeight := 0;
{set visibility}
SubReportFooterPage1a.Visible := (Report.PageNo = 1);
SubReportFooterPage1b.Visible := (Report.PageNo = 1);
SubReportFooterAllPages.Visible := (Report.PageNo = Report.PageCount);
{calc footer height}
if SubReportFooterPage1a.Visible then begin
totalHeight := totalHeight + SubReportFinancVoorbeeld.Height;
end;
if SubReportFooterPage1b.Visible then
begin
SubReportFooterPage1b.Top := TotalHeight;
totalHeight := totalHeight + SubReportGarPlus.Height;
end;
if SubReportFooterAllPages.Visible then
begin
SubReportFooterAllPages.Top := TotalHeight;
totalHeight := totalHeight + SubReportFooter.Height;
end;
{This footer contains a memo which stretches to the amount of text,
GetMemoHeight is a
self-made function that calculates the height of a given memo, with a
certain amount of text}
if SubReportFooterLastPage.Visible then
begin
localMemo := FindComponent(SubReportFooterLastPage.Report,
'DBVoetTekst');
if localMemo <> nil then
begin
localMemo.Height := GetMemoHeight(localMemo,
Document['DocumentVoetTekst']);
SubReportFooterLastPage.Height := localMemo.Height + 0.1;
end;
SubReportFooterLastPage.Top := TotalHeight;
totalHeight := totalHeight + SubReportFooterLastPage.Height;
end;
{increase height of footer for pagenumbers}
Footer.Height := totalHeight + (2 * LabelPageNo.Height);
LabelPageNo.Top := Footer.Height - LabelPageNo.Height;
dbFooterLine.Top := LabelPageNo.Top;
end;
I am trying to create a dynamic footer band in ReportBuilder 11.06 w/ Delphi
2007.
I need this because I have 3 types of footers, which are dynamic in height
and must be aligned to bottom.
- 2 footers should only print on the first page
- 1 should print on every page
- 1 should only print on the last page
The detailband contains a subreport that could get large (so I do not loop
through details in the mainreport).
So far I have managed to come up with the code below, placed in the
OnStartPage command. This creates the following problem (but only
sometimes):
- Report generates and calculates all bands.
- It detects that footer + detail band cannot fit on the last page and
breaks the detail to the next page.
- At this moment, the lastpage footer is also moved to the last page,
freeing up space on the second to last page and thus preventing the break.
This keeps going over and over again leading to a report that generates an
endless amount of pages when printing (preview seems to be OK), printing the
last page and page before over and over again.
Almost forgot to mention, the report is a 2-pass report.
Does anyone have any idea how to prevent this?
Roald van Doorn
procedure ReportOnStartPage;
var
localMemo : TppCustomMemo;
totalHeight : Double;
begin
{pre-reqs}
totalHeight := 0;
{set visibility}
SubReportFooterPage1a.Visible := (Report.PageNo = 1);
SubReportFooterPage1b.Visible := (Report.PageNo = 1);
SubReportFooterAllPages.Visible := (Report.PageNo = Report.PageCount);
{calc footer height}
if SubReportFooterPage1a.Visible then begin
totalHeight := totalHeight + SubReportFinancVoorbeeld.Height;
end;
if SubReportFooterPage1b.Visible then
begin
SubReportFooterPage1b.Top := TotalHeight;
totalHeight := totalHeight + SubReportGarPlus.Height;
end;
if SubReportFooterAllPages.Visible then
begin
SubReportFooterAllPages.Top := TotalHeight;
totalHeight := totalHeight + SubReportFooter.Height;
end;
{This footer contains a memo which stretches to the amount of text,
GetMemoHeight is a
self-made function that calculates the height of a given memo, with a
certain amount of text}
if SubReportFooterLastPage.Visible then
begin
localMemo := FindComponent(SubReportFooterLastPage.Report,
'DBVoetTekst');
if localMemo <> nil then
begin
localMemo.Height := GetMemoHeight(localMemo,
Document['DocumentVoetTekst']);
SubReportFooterLastPage.Height := localMemo.Height + 0.1;
end;
SubReportFooterLastPage.Top := TotalHeight;
totalHeight := totalHeight + SubReportFooterLastPage.Height;
end;
{increase height of footer for pagenumbers}
Footer.Height := totalHeight + (2 * LabelPageNo.Height);
LabelPageNo.Top := Footer.Height - LabelPageNo.Height;
dbFooterLine.Top := LabelPageNo.Top;
end;
This discussion has been closed.
Comments
Instead of using a footer in this case, perhaps try using the Summary Band
with the FooterBand.PrintOnLastPage := False.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks for your suggestion, I have been experimenting with this too. The
problem I had with this was that the footer that should go on every apge is
a 'signature' block for a contract, while the block that should only go on
the last page contains the 'small print.'
Preferably I wanted the small print _below_ the signature on the last page,
yet the signature at the bottom of the page for every other page. I
eventually solved this by setting PrintOnLastPage=False for the Footer and
copying the signature block to the summary band and setting this
AlignToBottom=True. Not as nice, but it works the way I want it to.
greetings,
Roald