Class PdfGridCell
- Namespace
- Syncfusion.Pdf.Grid
- Assembly
- Syncfusion.Pdf.Portable.dll
Represents the schema of a cell in a PdfGrid.
public class PdfGridCell
- Inheritance
-
PdfGridCell
- Inherited Members
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Create a DataTable.
DataTable dataTable = new DataTable("EmpDetails");
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//PDF grid cell
PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
//Set cell style.
cell.Style.BackgroundBrush = new PdfSolidBrush(Color.Red);
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, new PointF(10, 10));
//Save the document.
doc.Save("Output.pdf");
//close the document
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page.
Dim page As PdfPage = doc.Pages.Add()
'Create a PdfGrid.
Dim pdfGrid As New PdfGrid()
'Create a DataTable.
Dim dataTable As New DataTable("EmpDetails")
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
'Add rows to the DataTable.
dataTable.Rows.Add(New Object() { "E01", "Clay"})
dataTable.Rows.Add(New Object() { "E02", "Thomas"})
'Assign data source.
pdfGrid.DataSource = dataTable
'PDF grid cell
Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
'Set cell style.
cell.Style.BackgroundBrush = New PdfSolidBrush(Color.Red)
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Constructors
PdfGridCell()
Initializes a new instance of the PdfGridCell class.
public PdfGridCell()
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Create a DataTable.
DataTable dataTable = new DataTable("EmpDetails");
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//PDF grid cell
PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
//Set cell style.
cell.Style.BackgroundBrush = new PdfSolidBrush(Color.Red);
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, new PointF(10, 10));
//Save the document.
doc.Save("Output.pdf");
//close the document
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page.
Dim page As PdfPage = doc.Pages.Add()
'Create a PdfGrid.
Dim pdfGrid As New PdfGrid()
'Create a DataTable.
Dim dataTable As New DataTable("EmpDetails")
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
'Add rows to the DataTable.
dataTable.Rows.Add(New Object() { "E01", "Clay"})
dataTable.Rows.Add(New Object() { "E02", "Thomas"})
'Assign data source.
pdfGrid.DataSource = dataTable
'PDF grid cell
Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
'Set cell style.
cell.Style.BackgroundBrush = New PdfSolidBrush(Color.Red)
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
PdfGridCell(PdfGridRow)
Initializes a new instance of the PdfGridCell class with the row.
public PdfGridCell(PdfGridRow row)
Parameters
row
PdfGridRowThe row of the cell.
Properties
ColumnSpan
Gets or sets a value that indicates the total number of columns that cell spans within a PdfGrid.
public int ColumnSpan { get; set; }
Property Value
- int
The number of columns that cell should span. The default value is 1.
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Create a DataTable.
DataTable dataTable = new DataTable("EmpDetails");
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//PDF grid cell
PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
//Set row span
cell.RowSpan = 2;
//set column span.
cell.ColumnSpan = 2;
//Check whether the text is HTML text?
bool isHtmlText = cell.IsHtmlText;
//Set Value.
cell.Value = "George";
//Set string format.
cell.StringFormat.Alignment = PdfTextAlignment.Center;
//Set image position.
cell.ImagePosition = PdfGridImagePosition.Fit;
//Set PDF tag.
cell.PdfTag = new PdfStructureElement(PdfTagType.TableDataCell);
//Set cell style.
cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, new PointF(10, 10));
//Save the document.
doc.Save("Output.pdf");
//close the document
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page.
Dim page As PdfPage = doc.Pages.Add()
'Create a PdfGrid.
Dim pdfGrid As New PdfGrid()
'Create a DataTable.
Dim dataTable As New DataTable("EmpDetails")
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
'Add rows to the DataTable.
dataTable.Rows.Add(New Object() { "E01", "Clay"})
dataTable.Rows.Add(New Object() { "E02", "Thomas"})
'Assign data source.
pdfGrid.DataSource = dataTable
'PDF grid cell
Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
'Set row span
cell.RowSpan = 2;
'set column span.
cell.ColumnSpan = 2;
'Check whether the text is HTML text?
Dim isHtmlText As Boolean = cell.IsHtmlText
'Set Value.
cell.Value = "George"
'Set string format.
cell.StringFormat.Alignment = PdfTextAlignment.Center
'Set image position.
cell.ImagePosition = PdfGridImagePosition.Fit
'Set PDF tag.
cell.PdfTag = New PdfStructureElement(PdfTagType.TableDataCell)
'Set cell style.
cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Height
Gets the height of the PdfGrid cell.[Read-Only]
public float Height { get; }
Property Value
- float
The height.
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Create a DataTable.
DataTable dataTable = new DataTable("EmpDetails");
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//PDF grid cell
PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
//Set cell style.
cell.Style.BackgroundBrush = new PdfSolidBrush(Color.Red);
//Get cell width.
float cellWidth = cell.Width;
//Get cell height.
float cellHeight = cell.Height;
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, new PointF(10, 10));
//Save the document.
doc.Save("Output.pdf");
//close the document
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page.
Dim page As PdfPage = doc.Pages.Add()
'Create a PdfGrid.
Dim pdfGrid As New PdfGrid()
'Create a DataTable.
Dim dataTable As New DataTable("EmpDetails")
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
'Add rows to the DataTable.
dataTable.Rows.Add(New Object() { "E01", "Clay"})
dataTable.Rows.Add(New Object() { "E02", "Thomas"})
'Assign data source.
pdfGrid.DataSource = dataTable
'PDF grid cell
Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
'Set cell style.
cell.Style.BackgroundBrush = New PdfSolidBrush(Color.Red)
'Get cell width.
Dim cellWidth As Single = cell.Width
'Get cell height.
Dim cellHeight As Single = cell.Height
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
ImagePosition
Gets or sets the image alignment type of the PdfGridCell background image.
public PdfGridImagePosition ImagePosition { get; set; }
Property Value
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Create a DataTable.
DataTable dataTable = new DataTable("EmpDetails");
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//PDF grid cell
PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
//Set row span
cell.RowSpan = 2;
//set column span.
cell.ColumnSpan = 2;
//Check whether the text is HTML text?
bool isHtmlText = cell.IsHtmlText;
//Set Value.
cell.Value = "George";
//Set string format.
cell.StringFormat.Alignment = PdfTextAlignment.Center;
//Set image position.
cell.ImagePosition = PdfGridImagePosition.Fit;
//Set PDF tag.
cell.PdfTag = new PdfStructureElement(PdfTagType.TableDataCell);
//Set cell style.
cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, new PointF(10, 10));
//Save the document.
doc.Save("Output.pdf");
//close the document
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page.
Dim page As PdfPage = doc.Pages.Add()
'Create a PdfGrid.
Dim pdfGrid As New PdfGrid()
'Create a DataTable.
Dim dataTable As New DataTable("EmpDetails")
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
'Add rows to the DataTable.
dataTable.Rows.Add(New Object() { "E01", "Clay"})
dataTable.Rows.Add(New Object() { "E02", "Thomas"})
'Assign data source.
pdfGrid.DataSource = dataTable
'PDF grid cell
Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
'Set row span
cell.RowSpan = 2;
'set column span.
cell.ColumnSpan = 2;
'Check whether the text is HTML text?
Dim isHtmlText As Boolean = cell.IsHtmlText
'Set Value.
cell.Value = "George"
'Set string format.
cell.StringFormat.Alignment = PdfTextAlignment.Center
'Set image position.
cell.ImagePosition = PdfGridImagePosition.Fit
'Set PDF tag.
cell.PdfTag = New PdfStructureElement(PdfTagType.TableDataCell)
'Set cell style.
cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
IsHtmlText
Gets or sets the cell content is HTML text or not
public bool IsHtmlText { get; set; }
Property Value
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Create a DataTable.
DataTable dataTable = new DataTable("EmpDetails");
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//PDF grid cell
PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
//Set row span
cell.RowSpan = 2;
//set column span.
cell.ColumnSpan = 2;
//Check whether the text is HTML text?
bool isHtmlText = cell.IsHtmlText;
//Set Value.
cell.Value = "George";
//Set string format.
cell.StringFormat.Alignment = PdfTextAlignment.Center;
//Set image position.
cell.ImagePosition = PdfGridImagePosition.Fit;
//Set PDF tag.
cell.PdfTag = new PdfStructureElement(PdfTagType.TableDataCell);
//Set cell style.
cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, new PointF(10, 10));
//Save the document.
doc.Save("Output.pdf");
//close the document
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page.
Dim page As PdfPage = doc.Pages.Add()
'Create a PdfGrid.
Dim pdfGrid As New PdfGrid()
'Create a DataTable.
Dim dataTable As New DataTable("EmpDetails")
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
'Add rows to the DataTable.
dataTable.Rows.Add(New Object() { "E01", "Clay"})
dataTable.Rows.Add(New Object() { "E02", "Thomas"})
'Assign data source.
pdfGrid.DataSource = dataTable
'PDF grid cell
Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
'Set row span
cell.RowSpan = 2;
'set column span.
cell.ColumnSpan = 2;
'Check whether the text is HTML text?
Dim isHtmlText As Boolean = cell.IsHtmlText
'Set Value.
cell.Value = "George"
'Set string format.
cell.StringFormat.Alignment = PdfTextAlignment.Center
'Set image position.
cell.ImagePosition = PdfGridImagePosition.Fit
'Set PDF tag.
cell.PdfTag = New PdfStructureElement(PdfTagType.TableDataCell)
'Set cell style.
cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
PdfTag
Get or set the tag for the element
public PdfTag PdfTag { get; set; }
Property Value
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Create a DataTable.
DataTable dataTable = new DataTable("EmpDetails");
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//PDF grid cell
PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
//Set row span
cell.RowSpan = 2;
//set column span.
cell.ColumnSpan = 2;
//Check whether the text is HTML text?
bool isHtmlText = cell.IsHtmlText;
//Set Value.
cell.Value = "George";
//Set string format.
cell.StringFormat.Alignment = PdfTextAlignment.Center;
//Set image position.
cell.ImagePosition = PdfGridImagePosition.Fit;
//Set PDF tag.
cell.PdfTag = new PdfStructureElement(PdfTagType.TableDataCell);
//Set cell style.
cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, new PointF(10, 10));
//Save the document.
doc.Save("Output.pdf");
//close the document
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page.
Dim page As PdfPage = doc.Pages.Add()
'Create a PdfGrid.
Dim pdfGrid As New PdfGrid()
'Create a DataTable.
Dim dataTable As New DataTable("EmpDetails")
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
'Add rows to the DataTable.
dataTable.Rows.Add(New Object() { "E01", "Clay"})
dataTable.Rows.Add(New Object() { "E02", "Thomas"})
'Assign data source.
pdfGrid.DataSource = dataTable
'PDF grid cell
Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
'Set row span
cell.RowSpan = 2;
'set column span.
cell.ColumnSpan = 2;
'Check whether the text is HTML text?
Dim isHtmlText As Boolean = cell.IsHtmlText
'Set Value.
cell.Value = "George"
'Set string format.
cell.StringFormat.Alignment = PdfTextAlignment.Center
'Set image position.
cell.ImagePosition = PdfGridImagePosition.Fit
'Set PDF tag.
cell.PdfTag = New PdfStructureElement(PdfTagType.TableDataCell)
'Set cell style.
cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
RowSpan
Gets or sets a value that indicates the total number of rows that cell spans within a PdfGrid.
public int RowSpan { get; set; }
Property Value
- int
The number of rows that cell should span. The default value is 1.
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Create a DataTable.
DataTable dataTable = new DataTable("EmpDetails");
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//PDF grid cell
PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
//Set row span
cell.RowSpan = 2;
//set column span.
cell.ColumnSpan = 2;
//Check whether the text is HTML text?
bool isHtmlText = cell.IsHtmlText;
//Set Value.
cell.Value = "George";
//Set string format.
cell.StringFormat.Alignment = PdfTextAlignment.Center;
//Set image position.
cell.ImagePosition = PdfGridImagePosition.Fit;
//Set PDF tag.
cell.PdfTag = new PdfStructureElement(PdfTagType.TableDataCell);
//Set cell style.
cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, new PointF(10, 10));
//Save the document.
doc.Save("Output.pdf");
//close the document
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page.
Dim page As PdfPage = doc.Pages.Add()
'Create a PdfGrid.
Dim pdfGrid As New PdfGrid()
'Create a DataTable.
Dim dataTable As New DataTable("EmpDetails")
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
'Add rows to the DataTable.
dataTable.Rows.Add(New Object() { "E01", "Clay"})
dataTable.Rows.Add(New Object() { "E02", "Thomas"})
'Assign data source.
pdfGrid.DataSource = dataTable
'PDF grid cell
Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
'Set row span
cell.RowSpan = 2;
'set column span.
cell.ColumnSpan = 2;
'Check whether the text is HTML text?
Dim isHtmlText As Boolean = cell.IsHtmlText
'Set Value.
cell.Value = "George"
'Set string format.
cell.StringFormat.Alignment = PdfTextAlignment.Center
'Set image position.
cell.ImagePosition = PdfGridImagePosition.Fit
'Set PDF tag.
cell.PdfTag = New PdfStructureElement(PdfTagType.TableDataCell)
'Set cell style.
cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
StringFormat
Gets or sets the string format.
public PdfStringFormat StringFormat { get; set; }
Property Value
- PdfStringFormat
The string format.
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Create a DataTable.
DataTable dataTable = new DataTable("EmpDetails");
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//PDF grid cell
PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
//Set row span
cell.RowSpan = 2;
//set column span.
cell.ColumnSpan = 2;
//Check whether the text is HTML text?
bool isHtmlText = cell.IsHtmlText;
//Set Value.
cell.Value = "George";
//Set string format.
cell.StringFormat.Alignment = PdfTextAlignment.Center;
//Set image position.
cell.ImagePosition = PdfGridImagePosition.Fit;
//Set PDF tag.
cell.PdfTag = new PdfStructureElement(PdfTagType.TableDataCell);
//Set cell style.
cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, new PointF(10, 10));
//Save the document.
doc.Save("Output.pdf");
//close the document
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page.
Dim page As PdfPage = doc.Pages.Add()
'Create a PdfGrid.
Dim pdfGrid As New PdfGrid()
'Create a DataTable.
Dim dataTable As New DataTable("EmpDetails")
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
'Add rows to the DataTable.
dataTable.Rows.Add(New Object() { "E01", "Clay"})
dataTable.Rows.Add(New Object() { "E02", "Thomas"})
'Assign data source.
pdfGrid.DataSource = dataTable
'PDF grid cell
Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
'Set row span
cell.RowSpan = 2;
'set column span.
cell.ColumnSpan = 2;
'Check whether the text is HTML text?
Dim isHtmlText As Boolean = cell.IsHtmlText
'Set Value.
cell.Value = "George"
'Set string format.
cell.StringFormat.Alignment = PdfTextAlignment.Center
'Set image position.
cell.ImagePosition = PdfGridImagePosition.Fit
'Set PDF tag.
cell.PdfTag = New PdfStructureElement(PdfTagType.TableDataCell)
'Set cell style.
cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Style
Gets or sets the cell style.
public PdfGridCellStyle Style { get; set; }
Property Value
- PdfGridCellStyle
Represents the style information applied to individual cells within a PdfGrid.
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Create a DataTable.
DataTable dataTable = new DataTable("EmpDetails");
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//PDF grid cell
PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
//Set row span
cell.RowSpan = 2;
//set column span.
cell.ColumnSpan = 2;
//Check whether the text is HTML text?
bool isHtmlText = cell.IsHtmlText;
//Set Value.
cell.Value = "George";
//Set string format.
cell.StringFormat.Alignment = PdfTextAlignment.Center;
//Set image position.
cell.ImagePosition = PdfGridImagePosition.Fit;
//Set PDF tag.
cell.PdfTag = new PdfStructureElement(PdfTagType.TableDataCell);
//Set cell style.
cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, new PointF(10, 10));
//Save the document.
doc.Save("Output.pdf");
//close the document
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page.
Dim page As PdfPage = doc.Pages.Add()
'Create a PdfGrid.
Dim pdfGrid As New PdfGrid()
'Create a DataTable.
Dim dataTable As New DataTable("EmpDetails")
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
'Add rows to the DataTable.
dataTable.Rows.Add(New Object() { "E01", "Clay"})
dataTable.Rows.Add(New Object() { "E02", "Thomas"})
'Assign data source.
pdfGrid.DataSource = dataTable
'PDF grid cell
Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
'Set row span
cell.RowSpan = 2;
'set column span.
cell.ColumnSpan = 2;
'Check whether the text is HTML text?
Dim isHtmlText As Boolean = cell.IsHtmlText
'Set Value.
cell.Value = "George"
'Set string format.
cell.StringFormat.Alignment = PdfTextAlignment.Center
'Set image position.
cell.ImagePosition = PdfGridImagePosition.Fit
'Set PDF tag.
cell.PdfTag = New PdfStructureElement(PdfTagType.TableDataCell)
'Set cell style.
cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Value
Gets or sets the value of the cell.
public object Value { get; set; }
Property Value
- object
Value can be string or PdfGrid, PdfGrid will create a nested grid.
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Create a DataTable.
DataTable dataTable = new DataTable("EmpDetails");
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//PDF grid cell
PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
//Set row span
cell.RowSpan = 2;
//set column span.
cell.ColumnSpan = 2;
//Check whether the text is HTML text?
bool isHtmlText = cell.IsHtmlText;
//Set Value.
cell.Value = "George";
//Set string format.
cell.StringFormat.Alignment = PdfTextAlignment.Center;
//Set image position.
cell.ImagePosition = PdfGridImagePosition.Fit;
//Set PDF tag.
cell.PdfTag = new PdfStructureElement(PdfTagType.TableDataCell);
//Set cell style.
cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, new PointF(10, 10));
//Save the document.
doc.Save("Output.pdf");
//close the document
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page.
Dim page As PdfPage = doc.Pages.Add()
'Create a PdfGrid.
Dim pdfGrid As New PdfGrid()
'Create a DataTable.
Dim dataTable As New DataTable("EmpDetails")
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
'Add rows to the DataTable.
dataTable.Rows.Add(New Object() { "E01", "Clay"})
dataTable.Rows.Add(New Object() { "E02", "Thomas"})
'Assign data source.
pdfGrid.DataSource = dataTable
'PDF grid cell
Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
'Set row span
cell.RowSpan = 2;
'set column span.
cell.ColumnSpan = 2;
'Check whether the text is HTML text?
Dim isHtmlText As Boolean = cell.IsHtmlText
'Set Value.
cell.Value = "George"
'Set string format.
cell.StringFormat.Alignment = PdfTextAlignment.Center
'Set image position.
cell.ImagePosition = PdfGridImagePosition.Fit
'Set PDF tag.
cell.PdfTag = New PdfStructureElement(PdfTagType.TableDataCell)
'Set cell style.
cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Width
Gets the width of the PdfGrid cell.[Read-Only]
public float Width { get; }
Property Value
- float
The width of the cell which is set by the column width.
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Create a DataTable.
DataTable dataTable = new DataTable("EmpDetails");
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//PDF grid cell
PdfGridCell cell = pdfGrid.Rows[0].Cells[0];
//Set cell style.
cell.Style.BackgroundBrush = new PdfSolidBrush(Color.Red);
//Get cell width.
float cellWidth = cell.Width;
//Get cell height.
float cellHeight = cell.Height;
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, new PointF(10, 10));
//Save the document.
doc.Save("Output.pdf");
//close the document
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page.
Dim page As PdfPage = doc.Pages.Add()
'Create a PdfGrid.
Dim pdfGrid As New PdfGrid()
'Create a DataTable.
Dim dataTable As New DataTable("EmpDetails")
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
'Add rows to the DataTable.
dataTable.Rows.Add(New Object() { "E01", "Clay"})
dataTable.Rows.Add(New Object() { "E02", "Thomas"})
'Assign data source.
pdfGrid.DataSource = dataTable
'PDF grid cell
Dim cell As PdfGridCell = pdfGrid.Rows(0).Cells(0)
'Set cell style.
cell.Style.BackgroundBrush = New PdfSolidBrush(Color.Red)
'Get cell width.
Dim cellWidth As Single = cell.Width
'Get cell height.
Dim cellHeight As Single = cell.Height
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)