Enum PdfGridImagePosition
Specifies the alignment type.
Namespace: Syncfusion.Pdf.Graphics
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public enum PdfGridImagePosition
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)
Fields
Name | Description |
---|---|
Center | The image is rendered by center of the cell. |
Fit | To fit background image to the cell based on the cell with and height. |
Stretch | The image is stretched by the percentages required to fit the width and height of the cell. |
Tile | The imag is rendered by tile mode. |