//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); |