Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
147449 | Sep 11,2019 08:09 AM UTC | Sep 12,2019 12:43 PM UTC | Xamarin.Forms | 1 |
![]() |
Tags: PDF |
//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); |
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.