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.
Unfortunately, activation email could not send to your email. Please try again.

How to format cells in a 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:



Article ID: Published Date: Last Revised Date: Platform: Control:
832 04/30/2011 01/10/2017 Windows Forms PDF
Did you find this information helpful?
Ewen Wallace Jan 09, 2017
"This will work only with PDF.Legacy.Base" - so what works now?
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
Add Comment
You must log in to leave a comment

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.