How to Force a New Page From a Script
We want to programmatically start a new page (at times) before printing a databand. i..e. sometimes the databand should appear on the current page, sometimes it should start at the top of the next page.
We tried this by hooking the data band's BeforePrint event and then (sometimes) setting the DataBand.StartNewPage property.
This is not working. When it detects the need to start a new page, the data band prints on the current page, then the next record prints on a new page.
i.e. it is like the descision to use DataBand.StartNewPage has been made BEFORE the BeforePrint was called.
How can we do this?
This discussion has been closed.
Comments
Hello!
To insert a conditional page break immediately before the current line, call `Engine.StartNewPage()` within the `BeforePrint` handler:
private void Data1_BeforePrint(object sender, EventArgs e) { if (Convert.ToBoolean(Report.GetColumnValue(‘Items.ForceBreak’))) Engine.StartNewPage(); }