Stretching page footer

WesWes
edited 4:59AM in FastReport 4.0
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

Comments

  • Anu de DeusAnu de Deus Hampshire, UK
    edited 4:59AM
    You probably must use the CalcHeight method.
    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
  • Anu de DeusAnu de Deus Hampshire, UK
    edited 4:59AM
    Just thought of something else:
    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.
  • gordkgordk St.Catherines On. Canada.
    edited 4:59AM
    page footer cannot be stretched it is a fixed size.
    use a child or other footer.
  • edited 4:59AM
    Hi Wes,

    How did you manage to adjust height of PageFooter according to MemoView height.

    Wes wrote: »
    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

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.