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

How to save the data from fields in Xamarin form page to PdfGrid

Platform: Xamarin.Forms |
Control: PDF

How to save the data from fields in Xamarin form page to PdfGrid

The PdfGrid can be created with data fetched from different fields in Xamarin form page and can be drawn in a PDF document. The below code snippet demonstrates the same.


//Create the pdfdocument 
PdfDocument doc = new PdfDocument();
//Add the page
PdfPage page = doc.Pages.Add();
//Create a new PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Add three columns.
//Setting string format for all the columns of PdfGrid
PdfStringFormat format = new PdfStringFormat();
format.Alignment = PdfTextAlignment.Center;
format.LineAlignment = PdfVerticalAlignment.Bottom;
pdfGrid.Columns[0].Format = format;
pdfGrid.Columns[1].Format = format;
//Add header.
PdfGridRow pdfGridHeader = pdfGrid.Headers[0];
pdfGridHeader.Cells[0].Value = "Field";
pdfGridHeader.Cells[1].Value = "Data";
pdfGridHeader.Style.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 10, PdfFontStyle.Bold);
//Add rows.
PdfGridRow pdfGridRow1 = pdfGrid.Rows.Add();
pdfGridRow1.Cells[0].Value = "Name";
//Get the Name field from Xamarin form page
pdfGridRow1.Cells[1].Value = Name.Text;
PdfGridRow pdfGridRow2 = pdfGrid.Rows.Add();
pdfGridRow2.Cells[0].Value = "Address";
//Get the Address field from Xamarin form page
pdfGridRow2.Cells[1].Value = Address.Text;
PdfGridRow pdfGridRow3 = pdfGrid.Rows.Add();
pdfGridRow3.Cells[0].Value = "Account Number";
//Get the Account number field from Xamarin form page
pdfGridRow3.Cells[1].Value = Account.Text;
//Draw the PdfGrid.
pdfGrid.Draw(page, PointF.Empty);
//Save and close the modified document.
MemoryStream stream = new MemoryStream();


Sample link: 


2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

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

Up arrow icon

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