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

How to create multiple pages pdf document?

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

3 Replies

KC Karthikeyan Chandrasekar Syncfusion Team 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 



VA Vanderlei 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!



KC Karthikeyan Chandrasekar Syncfusion Team January 31, 2019 04:38 AM UTC

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

Regards, 
Karthikeyan  


Loader.
Live Chat Icon For mobile
Up arrow icon