Get vertical page position (i.e. top) of databand?
Posted: Sun Jan 31, 2021 1:10 pm
We have a report where we want to ensure that we have a page break before the last record if it's otherwise going to get printed below a certain place on the page.
Suppose we can fit 4 records on a page. Printing a report with 3 records would give us one page, a report with 4 records would give us two pages (first page records 1-3, second page record 4), a report with 5 records would give us records 1-4 on the first page, record 5 on the next page, 8 records would give 1-4 on first page, 5-7 on next page, record 8 on third page, etc.
We did have that working fine with a BeforePrint event on the databand to say that if we were about to print the last record and if the number of records mod 4 was zero, then to do an Engine.NewPage().
But now we're in the position that due to varying data, sometimes a page may hold 3 records, sometimes 4 or sometimes 5. Each record takes the same vertical height, it's just headers and footers than may vary.
So back to the opening problem - what we really want to do is to amend our BeforePrint event to say that if the databand position on the page is more than a certain way down the page, then we do our Engine.NewPage(). Or, of course, to do an AfterPrint event and test if we've just handled the last-but-one record.
But we can't work out how to get the "y" position of where we are on the page, or the Top of the databand?
Suppose we can fit 4 records on a page. Printing a report with 3 records would give us one page, a report with 4 records would give us two pages (first page records 1-3, second page record 4), a report with 5 records would give us records 1-4 on the first page, record 5 on the next page, 8 records would give 1-4 on first page, 5-7 on next page, record 8 on third page, etc.
We did have that working fine with a BeforePrint event on the databand to say that if we were about to print the last record and if the number of records mod 4 was zero, then to do an Engine.NewPage().
But now we're in the position that due to varying data, sometimes a page may hold 3 records, sometimes 4 or sometimes 5. Each record takes the same vertical height, it's just headers and footers than may vary.
So back to the opening problem - what we really want to do is to amend our BeforePrint event to say that if the databand position on the page is more than a certain way down the page, then we do our Engine.NewPage(). Or, of course, to do an AfterPrint event and test if we've just handled the last-but-one record.
But we can't work out how to get the "y" position of where we are on the page, or the Top of the databand?