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

Measure of a PdfGrid before draw or force a PdfGrid to insert a page break to fit completley on on page

Hi there

Is there a method to measure the size of a PdfGrid before I draw it to a page or can I set any properties to force the PdfGrid on one page?

I´m doing a complex layout so the content is variable. But I want the content of a specific PdfGrid not possibly allocated on two pages but only on one page. If there is not enough room left to fit it, a page break should be inserted.

Is there a way to archive this?

I found no way to measure the size of the PdfGrid before it is drawn and PdfGridLayoutFormat seems only to care for single rows, not for the whole PdfGrid. And besides it seems to remove sometimes Information of the grid. 

Any ideas?


Regards,
Walter Porada


1 Reply

PH Praveenkumar H Syncfusion Team November 13, 2014 12:14 PM UTC

Hi Walter,

Thank you for using Syncfusion product.

Currently Essential Pdf doesn’t have any property to get PdfGrid table height, we have created a   workaround to get the solution. We have created dummy PdfDcocument to get the height of the table.

 Please refer following the code snippet.

  //Calculate the Table Height

PdfLayoutResult result = pdfGrid.Draw(page, new PointF(0, 0));

 

float height = result.Bounds.Height;

If the element exceeds the page, pagination is used to proceed it on the next page. We can enable the pagination by using the Pagination property available in the PdfLayoutType enumeration. Please refer the following code snippet:

//Create the PdfGird

PdfGrid pdfGrid = new PdfGrid();

PdfGridLayoutFormat format = new PdfGridLayoutFormat();                   

format.Layout=PdfLayoutType.Paginate

format.Break = PdfLayoutBreakType.FitElement;

//Draws the grid in to the page of the PDF document using that layoutformat 

 pdfGrid.Draw(pdfPage, new PointF(10, 10),format);

We have attached the sample for your reference in below links

 

Sample Link to get PdfGrid Table Height:

http://www.syncfusion.com/downloads/support/directtrac/general/PdfGridTable1194063503.zip

 

Sample Link for Page break:

http://www.syncfusion.com/downloads/support/directtrac/general/PdfGridPageBreak1574123688.zip


Please try this and let us know if you have any further assistance.

Thanks,

Praveen.          


Loader.
Live Chat Icon For mobile
Up arrow icon