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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to create multiple pages pdf document?

Thread ID:

Created:

Updated:

Platform:

Replies:

142328 Jan 28,2019 10:23 PM UTC Jan 31,2019 04:38 AM UTC ASP.NET MVC - EJ 2 3
loading
Tags: PDF
Vanderlei
Asked On January 28, 2019 10:23 PM UTC

Hi guys,

Using EJ2, MVC5, VS2017...

I need to generate pdf reports that have multiple pages. I started by drawing data directly to page but when points exceeded first page a second page was not rendered correctly (data from second page was rendered in the first page header). Please kindly check bellow:


Sample from my code to generate pdf report using db data...




First page renders correctly:







I attached controller code and pdf generated. Please help me to achive multiple page pdf generation.

Thank you.

Attachment: Ensaio_5fd4daaf.zip

Karthikeyan Chandrasekar [Syncfusion]
Replied On January 29, 2019 04:56 PM UTC

Hi Vanderlei, 
In order to paginate the  text contents drawn using PdfTextElement  you may need to set layout Format for the text element as shown in the code below: 
//Set the properties to paginate the text. 
PdfLayoutFormat layoutFormat = new PdfLayoutFormat(); 
layoutFormat.Break = PdfLayoutBreakType.FitPage; 
layoutFormat.Layout = PdfLayoutType.Paginate; 
 
 
//Draw the text element with the properties and formats set. 
PdfTextLayoutResult result = element.Draw(page, bounds, layoutFormat); 
 
// Set bounds of next text based on last layout bounds 
bounds = new RectangleF( result.LastLineBounds.X , result.LastLineBounds.Y+20, page.Graphics.ClientSize.Width, page.Graphics.ClientSize.Height); 
 
// Use the  PdfTextLayoutResult Page propoerty whihch gets the last layout page after pagination. 
element.Draw(result.Page, bounds, layoutFormat); 



We have created a simple sample for the same it can be downloaded from below link: 
 
Please check if this helps to solve your issue. 
Regards, 
Karthikeyan 


Vanderlei
Replied On January 30, 2019 01:20 PM UTC

Hi Karthikeyan,

Now I am able to generate as many page as I need by using part of your suggested code.
Thank you so much!


Karthikeyan Chandrasekar [Syncfusion]
Replied On January 31, 2019 04:38 AM UTC

Hi Vanderlei, 
You are welcome and we are happy to know your issue is resolved. 

Regards, 
Karthikeyan  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon