Xamarin.Forms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class PdfGridImagePosition

    Show / Hide Table of Contents

    Class PdfGridImagePosition

    Specifies the alignment type.

    Inheritance
    System.Object
    PdfGridImagePosition
    Namespace: Syncfusion.Pdf.Graphics
    Assembly: Syncfusion.Pdf.Portable.dll
    Syntax
    public sealed class PdfGridImagePosition : Enum
    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

    Center

    The image is rendered by center of the cell.

    Declaration
    public const PdfGridImagePosition Center
    Field Value
    Type Description
    PdfGridImagePosition

    Fit

    To fit background image to the cell based on the cell with and height.

    Declaration
    public const PdfGridImagePosition Fit
    Field Value
    Type Description
    PdfGridImagePosition

    Stretch

    The image is stretched by the percentages required to fit the width and height of the cell.

    Declaration
    public const PdfGridImagePosition Stretch
    Field Value
    Type Description
    PdfGridImagePosition

    Tile

    The imag is rendered by tile mode.

    Declaration
    public const PdfGridImagePosition Tile
    Field Value
    Type Description
    PdfGridImagePosition

    value__

    Declaration
    public int value__
    Field Value
    Type Description
    System.Int32
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved