How to get the height of a PdfGrid?
You can get the height of a PdfGrid by using the PdfLayoutResult bounds property. To achieve this, you need to create a sample PdfDocument. Refer to the following code example.
C#
// Create a new document.
PdfDocument doc = new PdfDocument();
// Add a page
PdfPage page = doc.Pages.Add();
// Create Pdf graphics for the page
PdfGraphics graphics = page.Graphics;
PdfGrid pdfGrid = new PdfGrid();
DataTable table = CreateDataTable();
// Assign data source.
pdfGrid.DataSource = table;
// Calculate the PdfGridTable height
float gridHeight = 0.0f;
gridHeight = CalculateGridHeight(pdfGrid);
// Draws grid to the page of the PDF document.
pdfGrid.Draw(page, new PointF(10, 10));
// Saves the document.
doc.Save("Output.pdf");
doc.Close(true);
// Method used for calculating PdfGrid height
public float CalculateGridHeight(PdfGrid pdfGrid)
{
// Create a new document.
PdfDocument doc = new PdfDocument();
// Add a page
PdfPage page = doc.Pages.Add();
// Create Pdf graphics for the page
PdfGraphics graphics = page.Graphics;
// Draw the table
PdfLayoutResult result = pdfGrid.Draw(page, new PointF(0, 0));
float height = result.Bounds.Height;
// Close the document
doc.Close();
return height;
}
Sample Link:
http://www.syncfusion.com/downloads/support/directtrac/general/PdfGridTable1194063503-1709520221.zip