menu

Document Processing

ScopeType Class - C# PDF Library API Reference | Syncfusion

    Show / Hide Table of Contents

    ScopeType Class

    Represents the tag type

    Inheritance
    System.Object
    ScopeType
    Namespace: Syncfusion.Pdf
    Assembly: Syncfusion.Pdf.Base.dll
    Syntax
    public sealed class ScopeType : Enum
    Examples
     //Creates a new PDF document
     PdfDocument pdfDocument = new PdfDocument();
     pdfDocument.DocumentInformation.Title = "Table";
     //Adds new page
     PdfPage pdfPage = pdfDocument.Pages.Add();
     //Initialize the new structure element with tag type table
     PdfStructureElement element = new PdfStructureElement(PdfTagType.Table);
     //Create a new PdfGrid
     PdfGrid pdfGrid = new PdfGrid();
     //Adding tag to PDF grid
     pdfGrid.PdfTag = element;
     //Add three columns
     pdfGrid.Columns.Add(3);
     //Add header
     pdfGrid.Headers.Add(1);
     PdfGridRow pdfGridHeader = pdfGrid.Headers[0];
     pdfGridHeader.Style.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Bold);
     pdfGridHeader.Style.TextBrush = PdfBrushes.Brown;
     //Adding tag for each row with tag type TR
     pdfGridHeader.PdfTag = new PdfStructureElement(PdfTagType.TableRow);
     pdfGridHeader.Cells[0].Value = "Employee ID";
     //Adding tag for header cell with tag type TH
     pdfGridHeader.Cells[0].PdfTag = new PdfStructureElement(PdfTagType.TableHeader) { Scope = ScopeType.Both };
     pdfGridHeader.Cells[1].Value = "Employee Name";
     //Adding tag for header cell with tag type TH
     pdfGridHeader.Cells[1].PdfTag = new PdfStructureElement(PdfTagType.TableHeader) { Scope = ScopeType.Row};
     pdfGridHeader.Cells[2].Value = "Salary";
     //Adding tag for header cell with tag type TH
     pdfGridHeader.Cells[2].PdfTag = new PdfStructureElement(PdfTagType.TableHeader) { Scope = ScopeType.Column };
     //Add rows.
     PdfGridRow pdfGridRow = pdfGrid.Rows.Add();
     pdfGridRow.PdfTag = new PdfStructureElement(PdfTagType.TableRow);
     pdfGridRow.Cells[0].Value = "E01";
     pdfGridRow.Cells[1].Value = "Clay";
     pdfGridRow.Cells[2].Value = "$10,000";
     //Adding tag for each cell with tag type TD
     pdfGridRow.Cells[0].PdfTag = new PdfStructureElement(PdfTagType.TableDataCell);
     pdfGridRow.Cells[1].PdfTag = new PdfStructureElement(PdfTagType.TableDataCell);
     pdfGridRow.Cells[2].PdfTag = new PdfStructureElement(PdfTagType.TableDataCell);
     //Draw the PdfGrid
     pdfGrid.Draw(pdfPage, PointF.Empty);
     //save the document and dispose it
     pdfDocument.Save("Output.pdf");
     //close the document
     pdfDocument.Close(true);
    'Creates a new PDF document
     Dim pdfDocument As PdfDocument = New PdfDocument()
     pdfDocument.DocumentInformation.Title = "Table"
     'Adds new page
     Dim pdfPage As PdfPage = pdfDocument.Pages.Add()
     'Initialize the new structure element with tag type table
     Dim element As PdfStructureElement = New PdfStructureElement(PdfTagType.Table)
     'Create a new PdfGrid
     Dim pdfGrid As PdfGrid = New PdfGrid()
     'Adding tag to PDF grid
     pdfGrid.PdfTag = element
     'Add three columns
     pdfGrid.Columns.Add(3)
     'Add header.
     pdfGrid.Headers.Add(1)
     Dim pdfGridHeader As PdfGridRow = pdfGrid.Headers(0)
     pdfGridHeader.Style.Font = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Bold)
     pdfGridHeader.Style.TextBrush = PdfBrushes.Brown
     'Adding tag for each row with tag type TR
     pdfGridHeader.PdfTag = New PdfStructureElement(PdfTagType.TableRow)
     pdfGridHeader.Cells(0).Value = "Employee ID"
     'Adding tag for header cell with tag type TH
     pdfGridHeader.Cells(0).PdfTag = New PdfStructureElement(PdfTagType.TableHeader) With {.Scope = ScopeType.Row}
     pdfGridHeader.Cells(1).Value = "Employee Name"
     'Adding tag for header cell with tag type TH
     pdfGridHeader.Cells(0).PdfTag = New PdfStructureElement(PdfTagType.TableHeader) With {.Scope = ScopeType.Column}
     pdfGridHeader.Cells(2).Value = "Salary"
     'Adding tag for header cell with tag type TH
     pdfGridHeader.Cells(0).PdfTag = New PdfStructureElement(PdfTagType.TableHeader) With {.Scope = ScopeType.Both}
     'Add rows.
     Dim pdfGridRow As PdfGridRow = pdfGrid.Rows.Add()
     pdfGridRow.PdfTag = New PdfStructureElement(PdfTagType.TableRow)
     pdfGridRow.Cells(0).Value = "E01"
     pdfGridRow.Cells(1).Value = "Clay"
     pdfGridRow.Cells(2).Value = "$10,000"
     'Adding tag for each cell with tag type TD
     pdfGridRow.Cells(0).PdfTag = New PdfStructureElement(PdfTagType.TableDataCell)
     pdfGridRow.Cells(1).PdfTag = New PdfStructureElement(PdfTagType.TableDataCell)
     pdfGridRow.Cells(2).PdfTag = New PdfStructureElement(PdfTagType.TableDataCell)
     'Draw the PdfGrid
     pdfGrid.Draw(pdfPage, PointF.Empty)
     'save the document and dispose it
     pdfDocument.Save("Output.pdf")
     pdfDocument.Close(True)

    Fields

    Both

    Represents the Scope type as Both

    Declaration
    public const ScopeType Both
    Field Value
    Type
    ScopeType

    Column

    Represents the Scope type as Column

    Declaration
    public const ScopeType Column
    Field Value
    Type
    ScopeType

    None

    Represents the Scope type as None

    Declaration
    public const ScopeType None
    Field Value
    Type
    ScopeType

    Row

    Represents the Scope type as Row

    Declaration
    public const ScopeType Row
    Field Value
    Type
    ScopeType
    Back to top Generated by DocFX
    OSZAR »
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved
    OSZAR »