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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to paginate the text or table based on the table height?

Platform: WinForms |
Control: PDF
Tags: pdf, pdfgrid, text, table

How to paginate the text or table based on the table height?

The actual table height can be calculated before drawing in the PDF document.  Please refer the following example to achieve the above requirements:


//Create a new PDF document.
PdfDocument pdfDocument = new PdfDocument();
PdfPage pdfPage = pdfDocument.Pages.Add();
//Draw the grid
PdfGrid pdfGridTable = new PdfGrid();
pdfGridTable.RepeatHeader = true;
//Add columns.
//Add header.
PdfGridRow pdfGridHeader1 = pdfGridTable.Headers[0];
pdfGridHeader1.Cells[0].Value = "EMP NAME ";
pdfGridHeader1.Cells[1].Value = "ID";
//Add rows.
for (var i = 0; i < 23; ++i)
PdfGridRow pdfGridRow = pdfGridTable.Rows.Add();
pdfGridRow.Cells[0].Value = "Gilbert";
pdfGridRow.Cells[1].Value = "1796";
//Draw the PdfGrid.
PdfGridLayoutResult gridResult1 = pdfGridTable.Draw(page, new PointF(0,10));
//Draw the grid
PdfGrid pdfGrid = new PdfGrid();
pdfGrid.RepeatHeader = true;
//Adds columns.
//Adds header.
PdfGridRow pdfGridHeader = pdfGrid.Headers[0];
pdfGridHeader.Cells[0].Value = "EMP NAME ";
pdfGridHeader.Cells[1].Value = "ID";
//Add rows.
for (var i = 0; i < 30; ++i)
PdfGridRow pdfGridRow = pdfGrid.Rows.Add();
pdfGridRow.Cells[0].Value = "John";
pdfGridRow.Cells[1].Value = "1795";
//Get temp result of PDF grid for header and first row
PdfGridLayoutResult tempResult1 = GettempHeaderandRowLayoutResult(pdfGrid);
float bottom = gridResult1.Bounds.Bottom;
pdfPage = CheckPage(pdfDocument, gridResult1, tempResult1);
if (pdfPage != gridResult1.Page)
bottom = 0;
//Draw the PdfGrid.
PdfGridLayoutResult gridResult2 = pdfGrid.Draw(pdfPage, new PointF(0, bottom + 10));


Sample link:


2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

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

Up arrow icon

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