Page 1 of 1

"New page after" by code

Posted: Fri Mar 20, 2009 9:43 am
by mrapi
Hi.
Is there a way to set "New page after" by code,I need to create a report where user can select this.
Thanks.

"New page after" by code

Posted: Mon Mar 23, 2009 10:08 am
by Edward
Hi.

There is a method for starting of the new page in the EngineV2:

Engine.NewPage();

You can call it from any event inside the report.

Thank you.

"New page after" by code

Posted: Mon Mar 23, 2009 2:44 pm
by mrapi
Thanks Edward,this works !!!

"New page after" by code

Posted: Fri Mar 27, 2009 9:55 am
by Edward
Please let us know if we could assist you any further.

Thank you.

"New page after" by code

Posted: Sat Mar 28, 2009 12:16 pm
by mrapi
Thanks Edward
I'm using this code in GroupFooter "After Print" event

Code: Select all

If var_NewPageGrp=1 Then Engine.NewPage()
It works fine but it gives me +1 page blank at the end.This is normal, I need a more complex validaton for last group of data but how I'll do that.
Thanks a lot !

"New page after" by code

Posted: Mon Mar 30, 2009 9:57 am
by Edward
Hi

You can delete the last page from the collection of rendered pages in case if it is the empty page, for example. So you write the following code in the EndRender event of the report:

Code: Select all

StiPage lastPage = this.RenderedPages.Items(this.RenderedPages.Count-1);
if (lastPage.GetComponents().Count == 0)
{
	this.RenderedPages.RemoveAt(this.RenderedPages.Count-1);
}
 
Thank you.

"New page after" by code

Posted: Mon Mar 30, 2009 11:00 am
by mrapi
I can't convert this code to VB,I got errors ( error BC30469: Reference to a non-shared member requires an object reference.) and report is not compiled,I've tried this :

Code: Select all

Dim lastPage As New Stimulsoft.Report.Components.StiPage
If lastPage.GetComponents().Count = 0 Then
   Report.RenderedPages.RemoveAt(Report.RenderedPages.Count-1)
End If
My version is 2008.2
Thanks.

"New page after" by code

Posted: Mon Mar 30, 2009 11:13 am
by Edward
Please modify the code as follows:

Dim lastPage As Stimulsoft.Report.Components.StiPage = Me.RenderedPages.Items(Me.RenderedPages.Count-1)
If lastPage.GetComponents().Count = 0 Then
Me.RenderedPages.RemoveAt(Me.RenderedPages.Count-1)
End If

And there is a report in the attachment.

Thank you.

"New page after" by code

Posted: Mon Mar 30, 2009 11:26 am
by mrapi
Thanks Edward
This time report is compiled but when it is run I got
"Exception has been thrown of target of an invocation"
If I remove the event code, report works as before.
Thanks


"New page after" by code

Posted: Mon Mar 30, 2009 12:25 pm
by mrapi
Thanks Eduard,it works.
One mention : page footer elements like text objects ( for page numbering ) are also counted in .GetComponents().Count