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

Transform a collection of data into pdf

Thread ID:





145851 Jul 10,2019 05:18 PM UTC Jul 11,2019 08:31 AM UTC WinForms 1
Tags: PDF
Asked On July 10, 2019 05:18 PM UTC

How to transform a collection of data into pdf using the PdfDocument and/or PDF Viewer components
I have:
var dataReport = new object ();
dataReport = (from c in ctxt.vwDefrayalAndItems
                                           where c.ID.Equals (ReportId)
                                           select c) .ToArray ();

Sowmiya Loganathan [Syncfusion]
Replied On July 11, 2019 08:31 AM UTC

Hi Edvaldo, 

Thank you for contacting Syncfusion support. 

We can convert collection of data into PDF using PdfGrid. Please refer the below code snippet for more details, 

//Create a new PDF document 
PdfDocument doc = new PdfDocument(); 
//Add a page 
PdfPage page = doc.Pages.Add(); 
//Create a PdfGrid 
PdfGrid pdfGrid = new PdfGrid(); 
//Add values to list 
List<object> data = new List<object>(); 
Object row1 = new { ID = "1", Name = "Clay" }; 
Object row2 = new { ID = "2", Name = "Gray" }; 
Object row3 = new { ID = "3", Name = "Ash" }; 
//Add list to IEnumerable 
IEnumerable<object> tableData = data; 
//Assign data source 
pdfGrid.DataSource = tableData; 
//Draw grid to the page of PDF document 
pdfGrid.Draw(page, new PointF(10, 10)); 
//Save the document 
//close the document 

Kindly check with the above link, code snippet and let us know if it satisfies your requirement. If not please provide us further details about your requirement. It will helpful for us to provide the precise solution on this.  

Sowmiya L 


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