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

PdfGrid get Position of last Row

Hey, we're creating a dynamic PDF PdfGrid Table - and we want the next Element to show up just after the Table. 
Our current solution is the Y value of the element before + the pdfGrid.Row.Count * a fixed value,  but if the content is larger then usual the next elements may appear behind the Table and if it's smaller the distance is way to large 

Couldn't find a solution to get the Y position of the last pdfGrid element or the height of the pdfGrid itself

Hope somebody here can help! 


1 Reply

SL Sowmiya Loganathan Syncfusion Team September 12, 2019 12:43 PM UTC

Hi Benjamin, 

Thank you for contacting Syncfusion support.  

We have analyzed your requirement of “Adding element after drawing of PdfGrid in PDF document”. We can achieve your requirement by using PdfLayoutResult which returns the bounds of the table (X, Y, width and height) and current page of the table. Please find the below code snippet in which we have added the text element after the PDF grid.  

//Create a new PDF document 
PdfDocument document = new PdfDocument(); 
//Add a page 
PdfPage page = document.Pages.Add(); 
//Create a PdfGrid 
PdfGrid pdfGrid = new PdfGrid(); 
//Add values to list 
List<object> data = new List<object>(); 
for (int i = 0; i < 20; i++) 
    Object row1 = new { ID = "E01", Name = "Clay" }; 
    Object row2 = new { ID = "E02", Name = "Thomas" }; 
//Add list to IEnumerable 
IEnumerable<object> dataTable = data; 
//Assign data source 
pdfGrid.DataSource = dataTable; 
//Draw grid to the page of PDF document 
PdfLayoutResult result =pdfGrid.Draw(page, new Syncfusion.Drawing.PointF(10, 10)); 
//Create a text element with the text and font 
PdfTextElement textElement = new PdfTextElement(text, new PdfStandardFont(PdfFontFamily.TimesRoman, 14)); 
//Draw the text after grid element  
textElement.Draw(result.Page, new Syncfusion.Drawing.RectangleF(0, result.Bounds.Bottom +20, page.GetClientSize().Width, page.GetClientSize().Height)); 
//Save the document to the stream 
MemoryStream stream = new MemoryStream(); 

Please find the sample for the same from below, 
Output document link:  

Please try the above solution in your end and let us know if it satisfies your requirement.  

Sowmiya L 

Live Chat Icon For mobile
Up arrow icon