Table of Contents

Class PdfCellStyle

Namespace
Syncfusion.Pdf.Tables
Assembly
Syncfusion.Pdf.Portable.dll

Represents the information about the cell style.

public class PdfCellStyle
Inheritance
PdfCellStyle
Inherited Members

Examples

//Create PDF document
PdfDocument document = new PdfDocument();
//Create a new page
PdfPage page = document.Pages.Add();
//Set font
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 8);
//Create PdfPen for drawing border
PdfPen borderPen = new PdfPen(PdfBrushes.DarkBlue);
borderPen.Width = 0;
// Create default cell style
PdfCellStyle defaultStyle = new PdfCellStyle();
defaultStyle.Font = font;
defaultStyle.BackgroundBrush = PdfBrushes.White;
defaultStyle.BorderPen = borderPen;
//Create DataTable for source
DataTable dataTable = new DataTable("Table");
dataTable.Columns.Add("ID1");
dataTable.Columns[0].Caption = "id";
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Table Features Demo", "" };
dataTable.Rows.Add(values);
//Create the PdfLightTable
PdfLightTable table = new PdfLightTable();
table.DataSource = dataTable;
// Set the default cell style
table.Style.DefaultStyle = defaultStyle;
// Draw the table
table.Draw(page.Graphics, new PointF(0, 0));
//Save the document
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create PDF document
Dim document As New PdfDocument()
'Create a new page
Dim page As PdfPage = document.Pages.Add()
'Set font
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 8)
'Create PdfPen for drawing border
Dim borderPen As New PdfPen(PdfBrushes.DarkBlue)
borderPen.Width = 0
' Create default cell style
Dim defaultStyle As New PdfCellStyle()
defaultStyle.Font = font
defaultStyle.BackgroundBrush = PdfBrushes.White
defaultStyle.BorderPen = borderPen
'Create DataTable for source
Dim dataTable As New DataTable("Table")
dataTable.Columns.Add("ID1")
dataTable.Columns(0).Caption = "id"
dataTable.Columns.Add("ID2")
Dim values() As Object = { "Table Features Demo", "" }
dataTable.Rows.Add(values)
'Create PdfLightTable
Dim table As New PdfLightTable()
'Set the data source
table.DataSource = dataTable
' Set the default cell style
table.Style.DefaultStyle = defaultStyle
' Draw the table
table.Draw(page.Graphics, New PointF(0, 0))
'Save the document
document.Save("Output.pdf")
'Close the document
document.Close(True)

Constructors

PdfCellStyle()

Initializes a new instance of the PdfCellStyle class.

public PdfCellStyle()

Examples

//Create PDF document
PdfDocument document = new PdfDocument();
//Create a new page
PdfPage page = document.Pages.Add();
//Set font
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 8);
// Create default cell style
PdfCellStyle defaultStyle = new PdfCellStyle();
defaultStyle.Font = font;
defaultStyle.BackgroundBrush = PdfBrushes.Red;
defaultStyle.BorderPen = PdfPens.Blue;
//set the string format
defaultStyle.StringFormat = new PdfStringFormat(PdfTextAlignment.Justify);
//Create DataTable for source
DataTable dataTable = new DataTable("myTable");
dataTable.Columns.Add("ID1");
dataTable.Columns[0].Caption = "id";
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Table Features Demo", "" };
dataTable.Rows.Add(values);
// Create a new table
PdfLightTable table = new PdfLightTable();
table.DataSource = dataTable;
//Set the cell style
table.Style.DefaultStyle = defaultStyle;
// Draw the table
table.Draw(page, new PointF(0, 0));
//Save the document
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create PDF document
Dim document As New PdfDocument()
'Create a new page
Dim page As PdfPage = document.Pages.Add()
'Set font
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 8)
' Create default cell style
Dim defaultStyle As New PdfCellStyle()
defaultStyle.Font = font
defaultStyle.BackgroundBrush = PdfBrushes.Red
defaultStyle.BorderPen = PdfPens.Blue
'set the string format
defaultStyle.StringFormat = New PdfStringFormat(PdfTextAlignment.Justify)
'Create DataTable for source
Dim dataTable As New DataTable("myTable")
dataTable.Columns.Add("ID1")
dataTable.Columns(0).Caption = "id"
dataTable.Columns.Add("ID2")
Dim values() As Object = { "Table Features Demo", "" }
dataTable.Rows.Add(values)
' Create a new table
Dim table As New PdfLightTable()
table.DataSource = dataTable
'Set the cell style
table.Style.DefaultStyle = defaultStyle
' Draw the table
table.Draw(page, New PointF(0, 0))
'Save the document
document.Save("Output.pdf")
'Close the document
document.Close(True)
See Also

PdfCellStyle(PdfFont, PdfBrush, PdfPen)

Initializes a new instance of the PdfCellStyle class with specified font,brush and pen.

public PdfCellStyle(PdfFont font, PdfBrush fontBrush, PdfPen borderPen)

Parameters

font PdfFont

The font of the cell text.

fontBrush PdfBrush

the color which fills the cell text.

borderPen PdfPen

The color of the cell border.

Examples

//Create PDF document
PdfDocument document = new PdfDocument();
//Create a new page
PdfPage page = document.Pages.Add();
//Set font
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 8);
// Create default cell style
PdfCellStyle defaultStyle = new PdfCellStyle(font, PdfBrushes.Red, PdfPens.Blue);       
//set the string format
defaultStyle.StringFormat = new PdfStringFormat(PdfTextAlignment.Justify);
//Create DataTable for source
DataTable dataTable = new DataTable("myTable");
dataTable.Columns.Add("ID1");
dataTable.Columns[0].Caption = "id";
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Table Features Demo", "" };
dataTable.Rows.Add(values);
// Create a new table
PdfLightTable table = new PdfLightTable();
table.DataSource = dataTable;
//Set the cell style
table.Style.DefaultStyle = defaultStyle;
// Draw the table
table.Draw(page, new PointF(0, 0));
//Save the document
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create PDF document
Dim document As New PdfDocument()
'Create a new page
Dim page As PdfPage = document.Pages.Add()
'Set font
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 8)
' Create default cell style
Dim defaultStyle As New PdfCellStyle(font, PdfBrushes.Red, PdfPens.Blue)       
'set the string format
defaultStyle.StringFormat = New PdfStringFormat(PdfTextAlignment.Justify)
'Create DataTable for source
Dim dataTable As New DataTable("myTable")
dataTable.Columns.Add("ID1")
dataTable.Columns(0).Caption = "id"
dataTable.Columns.Add("ID2")
Dim values() As Object = { "Table Features Demo", "" }
dataTable.Rows.Add(values)
' Create a new table
Dim table As New PdfLightTable()
table.DataSource = dataTable
'Set the cell style
table.Style.DefaultStyle = defaultStyle
' Draw the table
table.Draw(page, New PointF(0, 0))
'Save the document
document.Save("Output.pdf")
'Close the document
document.Close(True)
See Also

Properties

BackgroundBrush

Gets or sets the color which fills the background of the cell.

public PdfBrush BackgroundBrush { get; set; }

Property Value

PdfBrush

Examples

//Create PDF document
PdfDocument document = new PdfDocument();
//Create a new page
PdfPage page = document.Pages.Add();
//Set font
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 8);
// Create default cell style
PdfCellStyle defaultStyle = new PdfCellStyle();
defaultStyle.Font = font;
defaultStyle.BackgroundBrush = PdfBrushes.Red;
defaultStyle.BorderPen = PdfPens.Blue;
//set the string format
defaultStyle.StringFormat = new PdfStringFormat(PdfTextAlignment.Justify);
//Create DataTable for source
DataTable dataTable = new DataTable("myTable");
dataTable.Columns.Add("ID1");
dataTable.Columns[0].Caption = "id";
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Table Features Demo", "" };
dataTable.Rows.Add(values);
// Create a new table
PdfLightTable table = new PdfLightTable();
table.DataSource = dataTable;
//Set the cell style
table.Style.DefaultStyle = defaultStyle;
// Draw the table
table.Draw(page, new PointF(0, 0));
//Save the document
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create PDF document
Dim document As New PdfDocument()
'Create a new page
Dim page As PdfPage = document.Pages.Add()
'Set font
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 8)
' Create default cell style
Dim defaultStyle As New PdfCellStyle()
defaultStyle.Font = font
defaultStyle.BackgroundBrush = PdfBrushes.Red
defaultStyle.BorderPen = PdfPens.Blue
'set the string format
defaultStyle.StringFormat = New PdfStringFormat(PdfTextAlignment.Justify)
'Create DataTable for source
Dim dataTable As New DataTable("myTable")
dataTable.Columns.Add("ID1")
dataTable.Columns(0).Caption = "id"
dataTable.Columns.Add("ID2")
Dim values() As Object = { "Table Features Demo", "" }
dataTable.Rows.Add(values)
' Create a new table
Dim table As New PdfLightTable()
table.DataSource = dataTable
'Set the cell style
table.Style.DefaultStyle = defaultStyle
' Draw the table
table.Draw(page, New PointF(0, 0))
'Save the document
document.Save("Output.pdf")
'Close the document
document.Close(True)

Remarks

It's null by default.

See Also

BorderPen

Gets or sets the color which draws the border of the cell.

public PdfPen BorderPen { get; set; }

Property Value

PdfPen

Examples

//Create PDF document
PdfDocument document = new PdfDocument();
//Create a new page
PdfPage page = document.Pages.Add();
// Create default cell style
PdfCellStyle defaultStyle = new PdfCellStyle();
defaultStyle.TextPen = PdfPens.BlueViolet;
defaultStyle.BorderPen = PdfPens.Black;
//Create DataTable for source
DataTable dataTable = new DataTable("Table");
dataTable.Columns.Add("ID1");
dataTable.Columns[0].Caption = "id";
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Table Features Demo", "" };
dataTable.Rows.Add(values);
// Create a new table
PdfLightTable table = new PdfLightTable();
table.DataSource = dataTable;
//Set the cell style
table.Style.DefaultStyle = defaultStyle;
// Draw the table
table.Draw(page, new PointF(0, 0));
//Save the document
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new page
Dim page As PdfPage = document.Pages.Add()
' Create default cell style
Dim defaultStyle As New PdfCellStyle()
'set the text brush
defaultStyle.TextBrush = PdfBrushes.BlueViolet
'set the border pen
defaultStyle.BorderPen = PdfPens.Black
'Create DataTable for source
Dim dataTable As New DataTable("Table")
dataTable.Columns.Add("ID1")
dataTable.Columns(0).Caption = "id"
dataTable.Columns.Add("ID2")
Dim values() As Object = { "Table Features Demo", "" }
dataTable.Rows.Add(values)
' Create a new table
Dim table As New PdfLightTable()
table.DataSource = dataTable
'Set the cell style
table.Style.DefaultStyle = defaultStyle
' Draw the table
table.Draw(page, New PointF(0, 0))
'Save the document
document.Save("Output.pdf")
'Close the document
document.Close(True)
See Also

Font

Gets or sets the font of the text.

public PdfFont Font { get; set; }

Property Value

PdfFont

Examples

//Create PDF document
PdfDocument document = new PdfDocument();
//Create a new page
PdfPage page = document.Pages.Add();
//Set font
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 8);
//Create PdfPen for drawing border
PdfPen borderPen = new PdfPen(PdfBrushes.DarkBlue);
borderPen.Width = 0;
// Create default cell style
PdfCellStyle defaultStyle = new PdfCellStyle();
defaultStyle.Font = font;
defaultStyle.BackgroundBrush = PdfBrushes.White;
defaultStyle.BorderPen = borderPen;
//Create DataTable for source
DataTable dataTable = new DataTable("Table");
dataTable.Columns.Add("ID1");
dataTable.Columns[0].Caption = "id";
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Table Features Demo", "" };
dataTable.Rows.Add(values);
//Create the PdfLightTable
PdfLightTable table = new PdfLightTable();
table.DataSource = dataTable;
// Set the default cell style
table.Style.DefaultStyle = defaultStyle;
// Draw the table
table.Draw(page.Graphics, new PointF(0, 0));
//Save the document
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create PDF document
Dim document As New PdfDocument()
'Create a new page
Dim page As PdfPage = document.Pages.Add()
'Set font
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 8)
'Create PdfPen for drawing border
Dim borderPen As New PdfPen(PdfBrushes.DarkBlue)
borderPen.Width = 0
' Create default cell style
Dim defaultStyle As New PdfCellStyle()
defaultStyle.Font = font
defaultStyle.BackgroundBrush = PdfBrushes.White
defaultStyle.BorderPen = borderPen
'Create DataTable for source
Dim dataTable As New DataTable("Table")
dataTable.Columns.Add("ID1")
dataTable.Columns(0).Caption = "id"
dataTable.Columns.Add("ID2")
Dim values() As Object = { "Table Features Demo", "" }
dataTable.Rows.Add(values)
'Create PdfLightTable
Dim table As New PdfLightTable()
'Set the data source
table.DataSource = dataTable
' Set the default cell style
table.Style.DefaultStyle = defaultStyle
' Draw the table
table.Draw(page.Graphics, New PointF(0, 0))
'Save the document
document.Save("Output.pdf")
'Close the document
document.Close(True)
See Also

StringFormat

Gets or sets the string format of the cell text.

public PdfStringFormat StringFormat { get; set; }

Property Value

PdfStringFormat

Examples

//Create PDF document
PdfDocument document = new PdfDocument();
//Create a new page
PdfPage page = document.Pages.Add();
//Set font
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 8);
// Create default cell style
PdfCellStyle defaultStyle = new PdfCellStyle();
defaultStyle.Font = font;
defaultStyle.BackgroundBrush = PdfBrushes.White;
defaultStyle.BorderPen = PdfPens.Blue;
//set the string format
defaultStyle.StringFormat = new PdfStringFormat(PdfTextAlignment.Justify);
//Create DataTable for source
DataTable dataTable = new DataTable("myTable");
dataTable.Columns.Add("ID1");
dataTable.Columns[0].Caption = "id";
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Table Features Demo", "" };
dataTable.Rows.Add(values);
// Create a new table
PdfLightTable table = new PdfLightTable();
table.DataSource = dataTable;
//Set the cell style
table.Style.DefaultStyle = defaultStyle;
// Draw the table
table.Draw(page, new PointF(0, 0));
//Save the document
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create PDF document
Dim document As New PdfDocument()
'Create a new page
Dim page As PdfPage = document.Pages.Add()
'Set font
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 8)
' Create default cell style
Dim defaultStyle As New PdfCellStyle()
defaultStyle.Font = font
defaultStyle.BackgroundBrush = PdfBrushes.White
defaultStyle.BorderPen = PdfPens.Blue
'set the string format
defaultStyle.StringFormat = New PdfStringFormat(PdfTextAlignment.Justify)
'Create DataTable for source
Dim dataTable As New DataTable("myTable")
dataTable.Columns.Add("ID1")
dataTable.Columns(0).Caption = "id"
dataTable.Columns.Add("ID2")
Dim values() As Object = { "Table Features Demo", "" }
dataTable.Rows.Add(values)
' Create a new table
Dim table As New PdfLightTable()
table.DataSource = dataTable
'Set the cell style
table.Style.DefaultStyle = defaultStyle
' Draw the table
table.Draw(page, New PointF(0, 0))
'Save the document
document.Save("Output.pdf")
'Close the document
document.Close(True)
See Also

TextBrush

Gets or sets the color which fills the cell text.

public PdfBrush TextBrush { get; set; }

Property Value

PdfBrush

Examples

//Create PDF document
PdfDocument document = new PdfDocument();
//Create a new page
PdfPage page = document.Pages.Add();
// Create default cell style
PdfCellStyle defaultStyle = new PdfCellStyle();
defaultStyle.TextPen = PdfPens.BlueViolet;
defaultStyle.BorderPen = PdfPens.Black;
//Create DataTable for source
DataTable dataTable = new DataTable("Table");
dataTable.Columns.Add("ID1");
dataTable.Columns[0].Caption = "id";
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Table Features Demo", "" };
dataTable.Rows.Add(values);
// Create a new table
PdfLightTable table = new PdfLightTable();
table.DataSource = dataTable;
//Set the cell style
table.Style.DefaultStyle = defaultStyle;
// Draw the table
table.Draw(page, new PointF(0, 0));
//Save the document
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new page
Dim page As PdfPage = document.Pages.Add()
' Create default cell style
Dim defaultStyle As New PdfCellStyle()
'set the text brush
defaultStyle.TextBrush = PdfBrushes.BlueViolet
'set the border pen
defaultStyle.BorderPen = PdfPens.Black
'Create DataTable for source
Dim dataTable As New DataTable("Table")
dataTable.Columns.Add("ID1")
dataTable.Columns(0).Caption = "id"
dataTable.Columns.Add("ID2")
Dim values() As Object = { "Table Features Demo", "" }
dataTable.Rows.Add(values)
' Create a new table
Dim table As New PdfLightTable()
table.DataSource = dataTable
'Set the cell style
table.Style.DefaultStyle = defaultStyle
' Draw the table
table.Draw(page, New PointF(0, 0))
'Save the document
document.Save("Output.pdf")
'Close the document
document.Close(True)

Remarks

This brush will be used to fill glyphs interior, which is the default.

See Also

TextPen

Gets or sets the color which draws the text outlines.

public PdfPen TextPen { get; set; }

Property Value

PdfPen

Examples

//Create PDF document
PdfDocument document = new PdfDocument();
//Create a new page
PdfPage page = document.Pages.Add();
// Create default cell style
PdfCellStyle defaultStyle = new PdfCellStyle();
defaultStyle.TextPen = PdfPens.BlueViolet;
defaultStyle.BorderPen = PdfPens.Black;
//Create DataTable for source
DataTable dataTable = new DataTable("Table");
dataTable.Columns.Add("ID1");
dataTable.Columns[0].Caption = "id";
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Table Features Demo", "" };
dataTable.Rows.Add(values);
// Create a new table
PdfLightTable table = new PdfLightTable();
table.DataSource = dataTable;
//Set the cell style
table.Style.DefaultStyle = defaultStyle;
// Draw the table
table.Draw(page, new PointF(0, 0));
//Save the document
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create PDF document
Dim document As New PdfDocument()
'Create a new page
Dim page As PdfPage = document.Pages.Add()
' Create default cell style
Dim defaultStyle As New PdfCellStyle()
defaultStyle.TextPen = PdfPens.BlueViolet
defaultStyle.BorderPen = PdfPens.Black
'Create DataTable for source
Dim dataTable As New DataTable("Table")
dataTable.Columns.Add("ID1")
dataTable.Columns(0).Caption = "id"
dataTable.Columns.Add("ID2")
Dim values() As Object = { "Table Features Demo", "" }
dataTable.Rows.Add(values)
' Create a new table
Dim table As New PdfLightTable()
table.DataSource = dataTable
'Set the cell style
table.Style.DefaultStyle = defaultStyle
' Draw the table
table.Draw(page, New PointF(0, 0))
'Save the document
document.Save("Output.pdf")
'Close the document
document.Close(True)

Remarks

It should be null for default text representation.

See Also

See Also