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 format cells in a PDF Table?

Platform: WinForms |
Control: PDF
Tags: pdf, pdfgrid

Format cells in PDF table

All the cells in a PDF Grid have a style object associated with it. The properties of the style object can be set as shown in the code snippet below.


//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Acquire page's graphics.
PdfGraphics graphics = page.Graphics;
//Create a PdfGrid.
PdfGrid table = new PdfGrid();
//Create a DataTable.
DataTable dataTable = new DataTable();
//Add columns to the DataTable
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
dataTable.Rows.Add(new object[] { "E03", "George" });
//Assign data source.
table.DataSource = dataTable;
// To set the backcolor.
table.Rows[1].Cells[1].Style.BackgroundBrush= Color.Red;
//Alignment of the text inside the cell.
table.Rows[1].Cells[0].Style.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 8f);
table.Rows[1].Cells[1].Style.StringFormat = new PdfStringFormat(PdfTextAlignment.Center);
table.Rows[1].Cells[2].Style.StringFormat = new PdfStringFormat(PdfTextAlignment.Right);
table.Rows[1].Cells[0].Style.StringFormat = new PdfStringFormat(PdfTextAlignment.Left);
table.Draw(page, new PointF(10, 10));
//Save the document.
//close the document.

Sample link:


2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment
Ewen Wallace
Jan 09, 2017
"This will work only with PDF.Legacy.Base" - so what works now? Reply
Gayathri Ramalingam [Syncfusion]
Jan 11, 2017
Hi Ewen,
Thank you for your feedback, we have refreshed this KB content to support for the new Syncfusion.Pdf.Base.

Gayathri R

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