Can grow, hmmm... that will throw some more monkeys into the mix.
What I would suggest is a series of formulas that update 1 shared variable, and this variable would be checked in the new page before formula. Unfortunately, there isn't a way that I know of to check the actual height of an item at run time.
Each section that is displayed would get a formula, luckily most don't size. The generic formula would be something like:
shared numbervar printLength := printLength + (sectionHeight);
"" // hides the calculation
For the page header section, it would just assign the height of the section like:
shared numbervar printLength := (sectionHeight);
"" // hides the calculation
Hopefully, not too many fields are set to can grow, but I would probably attack it like this:
shared numbervar pageLength;
local numbervar itemHeight;
itemHeight := len({table.field1})/x
if len({table.field2})/x > itemHeight then
itemHeight := len({table.field2})/x
...
//off the top of my head I don''t know if round, fix, cint will give the next number up. if item.Height=1.3, you want to make it 2, so maybe adding 1 and then using FIX or cint will give you an integral number
pageLength := sectionHeight * itemHeight;
""
that should give you a good start. X is some length that would cause the field to grow to multiple lines. The new page before will then look at the shared variable and compare it to the length of the page desired...something like:
shared numbervar pageLength;
pageLength + thisSectionHeight > x
or pageLenght + thisSectionHeight + NextSectionHeight > x
HTH