We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

PdfElements flow in multiple pages

Hi,
We are currently developing a project that we have to generate many lengthy PDF reports.
Each PDF consist of many elements (Text Elements, Grids, Images, (Un)ordered Lists etc) and the presentation order of these elements is determined by many variables.
Even the visibility of those elements is not constant.

I would like to ask if there is an easy way to draw all these elements in multiple pages without checking for each one if it fits into the current page and if not to create a new page manually?



3 Replies

GM Geetha M Syncfusion Team October 25, 2010 10:04 AM UTC

Hi Antonis,

Thank you for your continued interest in Syncfusion products.

All the elements you mentioned (Text Elements, Grids, Images and Unordered Lists) are associated with Begin and End PageLayoutEvents, from which you can get the end bounds and the page information. You can make use of these informations and calculate the starting location of the next element. I have created a simple sample and placed it in the link below.

F97048.zip

Please try this and let me know if you have any questions.

Regards,
Geetha



AM Antonis Mylonas October 25, 2010 02:34 PM UTC

Hi Geetha,
Thanks for your help.

Unfortunately it does not always work (please replace the manual.txt file, with the one attached and rerun the example you have sent me) due to the fact that you increment the Y property to leave space between the Pdf elements (this is something we do also)

i.e.
//Draw list
list.Draw(page, new PointF(0, pagebounds.Bottom + 10));

The above increment by 10 of the Y property, if it gets out of page bounds then it does not create a new page and instead is drawn on the top of the existing page.

We have tried result.Bounds.Inflate(0, 10) and result.Bounds.Offset(0, 10) but both methods do not work.

Is there any other way to overcome this problem.

Thanks & Regards
AM




WebSite1_5ae5bd9d.rar


GM Geetha M Syncfusion Team October 26, 2010 11:00 AM UTC

Hi Antonis,

Thank you for the details.

We can calculate whether the y coordinate has crossed the page bounds or not. Please refer to the code below:

float y = pagebounds.Bottom + 10;

if (y > page.GetClientSize().Height - 10)
{
page = doc.Pages.Add();
y = 0;
}

result = element.Draw(page, new PointF(0, y), layoutFormat);

Here -10 should be the constant value to leave space at the end of the page. Please try this and let me know if you have any questions.

Regards,
Geetha


Loader.
Live Chat Icon For mobile
Up arrow icon