Class PdfCellStyle
Represents the information about the cell style.
Inheritance
System.Object
PdfCellStyle
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Syncfusion.Pdf.Tables
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class 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 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.
Declaration
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)
PdfCellStyle(PdfFont, PdfBrush, PdfPen)
Initializes a new instance of the PdfCellStyle class with specified font,brush and pen.
Declaration
public PdfCellStyle(PdfFont font, PdfBrush fontBrush, PdfPen borderPen)
Parameters
Type | Name | Description |
---|---|---|
PdfFont | font | The font of the cell text. |
PdfBrush | fontBrush | the color which fills the cell text. |
PdfPen | borderPen | 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)
Properties
BackgroundBrush
Gets or sets the color which fills the background of the cell.
Declaration
public PdfBrush BackgroundBrush { get; set; }
Property Value
Type |
---|
PdfBrush |
Remarks
It's null by default.
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
BorderPen
Gets or sets the color which draws the border of the cell.
Declaration
public PdfPen BorderPen { get; set; }
Property Value
Type |
---|
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.
Declaration
public PdfFont Font { get; set; }
Property Value
Type |
---|
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.
Declaration
public PdfStringFormat StringFormat { get; set; }
Property Value
Type |
---|
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.
Declaration
public PdfBrush TextBrush { get; set; }
Property Value
Type |
---|
PdfBrush |
Remarks
This brush will be used to fill glyphs interior, which is the default.
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
TextPen
Gets or sets the color which draws the text outlines.
Declaration
public PdfPen TextPen { get; set; }
Property Value
Type |
---|
PdfPen |
Remarks
It should be null for default text representation.
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)