Stretching page footer
Hi all,
Just wanting to find out what the best way is to tackle what I'm wanting to do.
Before a report is printed, the user is prompted to enter some comments. This can be one line, fifteen lines, or whatever. These comments are entered into the PageFooter band. I've managed to get the footer to expand correctly now to fit whatever number of lines are in this comment. My problem now is that if the comment is too big, the PageFooter expands upwards up over the text in the main body of the report.
So what I want to know, is what is the right way to auto-size the PageFooter band at run-time, so that the available page body space is shrunk appropriately?
Thanks,
Wes
Just wanting to find out what the best way is to tackle what I'm wanting to do.
Before a report is printed, the user is prompted to enter some comments. This can be one line, fifteen lines, or whatever. These comments are entered into the PageFooter band. I've managed to get the footer to expand correctly now to fit whatever number of lines are in this comment. My problem now is that if the comment is too big, the PageFooter expands upwards up over the text in the main body of the report.
So what I want to know, is what is the right way to auto-size the PageFooter band at run-time, so that the available page body space is shrunk appropriately?
Thanks,
Wes
Comments
It basically calculates what will be the height of the object (MemoView) with the current text and font properties.
I use it in my Delphi units, not in the scripts, but I suppose it will work in the scripts too.
Take a look at this sample code of mine, where I manually set a band height according to a specific memo object:
if (lMemo.Calcheight + 1) > lDataBand.Height then
lDataBand.Height := lMemo.Calcheight + 1
You probably need something like:
if Footer.calcheight + Band.height > page.height then
Band.Height := Page.height - Footer.CalcHeight
Of course, I just put one band in the example, you must add all the bands that come above the footer to find out how big it is.
The second challenge you will have is to find the right event to do that, I would start trying with the onBeforePrint of the footer, but maybe you need it to be on the OnBeforePrint of the last band before it.
Just pay attention to the difference between a memo.height and memo.calcheight: the memo.height is the current height, so probably will be whatever you left at design time, unless you are reading it in an event after it has already been modified by the report itself. And the CalcHeight will calculate what the height WILL be for the current conditions, after it has auto stretched itself to acomodate all the text you have.
Hope it helps
Create your footer BAND with the maximum possible size that fits your page design, i.e. using all the space between the end of your last band and the end of the page.
Inside, put your footer MemoView (the one with the user's comments), with align = alClient, but with text justification (VAlign) to the bottom.
use a child or other footer.
How did you manage to adjust height of PageFooter according to MemoView height.