Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
145851 | Jul 10,2019 05:18 PM UTC | Jul 11,2019 08:31 AM UTC | WinForms | 1 |
![]() |
Tags: PDF |
//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" };
data.Add(row1);
data.Add(row2);
data.Add(row3);
//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
doc.Save("Sample.pdf");
//close the document
doc.Close(true); |
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.
This page will automatically be redirected to the sign-in page in 10 seconds.