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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

PdfGrid get Position of last Row

Thread ID:

Created:

Updated:

Platform:

Replies:

147449 Sep 11,2019 08:09 AM UTC Sep 12,2019 12:43 PM UTC Xamarin.Forms 1
loading
Tags: PDF
Benjamin Trudel
Asked On September 11, 2019 08:09 AM UTC

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! 



Regards 
Ben

Sowmiya Loganathan [Syncfusion]
Replied On 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" }; 
    data.Add(row1); 
    data.Add(row2); 
} 
//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(); 
document.Save(stream); 

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.  

Regards, 
Sowmiya L 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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
Live Chat Icon