Xamarin.Forms

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

    Show / Hide Table of Contents

    Class PdfSectionCollection

    Represents the collection of the PdfSection.

    Inheritance
    System.Object
    PdfSectionCollection
    Implements
    System.Collections.IEnumerable
    Namespace: Syncfusion.Pdf
    Assembly: Syncfusion.Pdf.Portable.dll
    Syntax
    public class PdfSectionCollection : Object, IPdfWrapper, IEnumerable
    Examples
    //Create a new PDF document.
    PdfDocument document = new PdfDocument();
    //Get the document section collection.
    PdfSectionCollection sections = document.Sections;
    //Add the section.
    PdfSection section = sections.Add();
    //Add pages to the section.
    PdfPage page = section.Pages.Add();
    //Create PDF graphics for the page.
    PdfGraphics graphics = page.Graphics;
    //Set the font.
    PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20);
    //Draw the text.
    graphics.DrawString("Hello World!!!", font, PdfBrushes.Black, new PointF(0, 0));
    //Save the document.
    document.Save("Output.pdf");
    //Close the document.
    document.Close(true);
    'Create a new PDF document.
    Dim document As New PdfDocument()
    'Get the document section collection.
    Dim sections As PdfSectionCollection = document.Sections
    'Add the section.
    Dim section As PdfSection = sections.Add()
    'Add pages to the section.
    Dim page As PdfPage = section.Pages.Add()
    'Create PDF graphics for the page.
    Dim graphics As PdfGraphics = page.Graphics
    'Set the font.
    Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 20)
    'Draw the text.
    graphics.DrawString("Hello World!!!", font, PdfBrushes.Black, New PointF(0, 0))
    'Save the document.
    document.Save("Output.pdf")
    'Close the document.
    document.Close(True)

    Properties

    Count

    Gets the total number of PdfSection in a document.Read only.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    System.Int32

    The count of the sections.

    Examples
    //Create a new PDF document.
    PdfDocument document = new PdfDocument();
    //Add the section.
    PdfSection section = document.Sections.Add();
    //Add pages to the section.
    PdfPage page = section.Pages.Add();
    //Add another section.
    PdfSection section1 = document.Sections.Add();
    //Add pages to the section1.
    PdfPage page1 = section1.Pages.Add();
    //Get the sections count.
    int count = document.Sections.Count;
    //Save the document.
    document.Save("Output.pdf");
    //Close the document.
    document.Close(true);
    'Create a new PDF document.
    Dim document As New PdfDocument()
    'Add the section.
    Dim section As PdfSection = document.Sections.Add()
    'Add pages to the section.
    Dim page As PdfPage = section.Pages.Add()
    'Add another section.
    Dim section1 As PdfSection = document.Sections.Add()
    'Add pages to the section1.
    Dim page1 As PdfPage = section1.Pages.Add()
    'Get the sections count.
    Dim count As Integer = document.Sections.Count
    'Save the document.
    document.Save("Output.pdf")
    'Close the document.
    document.Close(True)
    See Also
    PdfDocument
    PdfPage

    Item[Int32]

    Gets the PdfSection at the specified index.Read only.

    Declaration
    public PdfSection this[int index] { get; }
    Parameters
    Type Name Description
    System.Int32 index
    Property Value
    Type Description
    PdfSection
    Examples
    //Create a new PDF document.
    PdfDocument document = new PdfDocument();
    //Add the section.
    PdfSection section = document.Sections.Add();
    //Add pages to the section1.
    PdfPage page = section.Pages.Add();
    //Get the section from collection.
    PdfSection section2 = document.Sections[0];
    //Save the document.
    document.Save("Output.pdf");
    //Close the document.
    document.Close(true);
    'Create a new PDF document.
    Dim document As New PdfDocument()
    'Add the section.
    Dim section As PdfSection = document.Sections.Add()
    'Add pages to the section1.
    Dim page As PdfPage = section.Pages.Add()
    'Get the section from collection.
    Dim section2 As PdfSection = document.Sections(0)
    'Save the document.
    document.Save("Output.pdf")
    'Close the document.
    document.Close(True)
    See Also
    PdfDocument
    PdfPage

    Methods

    Add()

    Creates a new PdfSection and adds it to the collection.

    Declaration
    public PdfSection Add()
    Returns
    Type Description
    PdfSection

    Created section object.

    Examples
    //Create a new PDF document.
    PdfDocument document = new PdfDocument();
    //Add the section.
    PdfSection section = document.Sections.Add();
    //Add pages to the section.
    PdfPage page = section.Pages.Add();
    //Add another section.
    PdfSection section1 = document.Sections.Add();
    //Add the pages to section1.
    PdfPage page1 = section1.Pages.Add();
    //Create PDF graphics for the page.
    PdfGraphics graphics = page.Graphics;
    //Set the font.
    PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20);
    //Draw the text.
    graphics.DrawString("Hello World!!!", font, PdfBrushes.Black, new PointF(0, 0));
    //Save the document.
    document.Save("Output.pdf");
    //Close the document.
    document.Close(true);
    'Create a new PDF document.
    Dim document As New PdfDocument()
    'Add the section.
    Dim section As PdfSection = document.Sections.Add()
    'Add pages to the section.
    Dim page As PdfPage = section.Pages.Add()
    'Add another section.
    Dim section1 As PdfSection = document.Sections.Add()
    'Add the pages to section1.
    Dim page1 As PdfPage = section1.Pages.Add()
    'Create PDF graphics for the page.
    Dim graphics As PdfGraphics = page.Graphics
    'Set the font.
    Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 20)
    'Draw the text.
    graphics.DrawString("Hello World!!!", font, PdfBrushes.Black, New PointF(0, 0))
    'Save the document.
    document.Save("Output.pdf")
    'Close the document.
    document.Close(True)
    See Also
    PdfDocument
    PdfPage

    Contains(PdfSection)

    Checks whether the collection contains the specified section.

    Declaration
    public bool Contains(PdfSection section)
    Parameters
    Type Name Description
    PdfSection section

    The PdfSection

    Returns
    Type Description
    System.Boolean

    True - if the sections belongs to the collection, False otherwise.

    Examples
    //Create a new PDF document.
    PdfDocument document = new PdfDocument();
    //Add the section
    PdfSection section = document.Sections.Add();
    //Add pages to the section
    PdfPage page = section.Pages.Add();
    //Add the section
    PdfSection section1 = document.Sections.Add();
    //Add pages to the section1
    PdfPage page1 = section1.Pages.Add();
    //Check whether the specified section is in the collection
    bool isExists = document.Sections.Contains(section1);
    //Save the document.
    document.Save("Output.pdf");
    //Close the document.
    document.Close(true);
    'Create a new PDF document.
    Dim document As New PdfDocument()
    'Add the section
    Dim section As PdfSection = document.Sections.Add()
    'Add pages to the section
    Dim page As PdfPage = section.Pages.Add()
    'Add the section
    Dim section1 As PdfSection = document.Sections.Add()
    'Add pages to the section1
    Dim page1 As PdfPage = section1.Pages.Add()
    'Check whether the specified section is in the collection
    Dim isExists As Boolean = document.Sections.Contains(section1)
    'Save the document.
    document.Save("Output.pdf")
    'Close the document.
    document.Close(True)

    GetEnumerator()

    Returns an enumerator that iterates through a collection.

    Declaration
    public IEnumerator GetEnumerator()
    Returns
    Type Description
    System.Collections.IEnumerator

    An System.Collections.IEnumerator object that can be used to iterate through the collection.

    IndexOf(PdfSection)

    Determines the index of the specified PdfSection .

    Declaration
    public int IndexOf(PdfSection section)
    Parameters
    Type Name Description
    PdfSection section

    The section which is to be found the index.

    Returns
    Type Description
    System.Int32

    The index of the specified section.

    Examples
    //Create a new PDF document.
    PdfDocument document = new PdfDocument();
    //Add the section.
    PdfSection section = document.Sections.Add();
    //Add pages to the section.
    PdfPage page = section.Pages.Add();
    //Add another section.
    PdfSection section1 = document.Sections.Add();
    //Add pages to the section1.
    PdfPage page1 = section1.Pages.Add();
    //Get the index of the specified section.
    int index = document.Sections.IndexOf(section);
    //Save the document.
    document.Save("Output.pdf");
    //Close the document.
    document.Close(true);
    'Create a new PDF document.
    Dim document As New PdfDocument()
    'Add the section.
    Dim section As PdfSection = document.Sections.Add()
    'Add pages to the section.
    Dim page As PdfPage = section.Pages.Add()
    'Add another section.
    Dim section1 As PdfSection = document.Sections.Add()
    'Add pages to the section1.
    Dim page1 As PdfPage = section1.Pages.Add()
    'Get the index of the specified section.
    Dim index As Integer = document.Sections.IndexOf(section)
    'Save the document.
    document.Save("Output.pdf")
    'Close the document.
    document.Close(True)
    See Also
    PdfDocument
    PdfPage

    Insert(Int32, PdfSection)

    Inserts the PdfSection at the specified index.

    Declaration
    public void Insert(int index, PdfSection section)
    Parameters
    Type Name Description
    System.Int32 index

    The index of the section to be added.

    PdfSection section

    The section to be added.

    Remarks

    Index value should start from zero.

    Examples
    //Create a new PDF document.
    PdfDocument document = new PdfDocument();
    //Add the section.
    PdfSection section = document.Sections.Add();
    //Add pages to the section.
    PdfPage page = section.Pages.Add();
    //Add the section.
    PdfSection section1 = document.Sections.Add();
    //Add pages to the section1.
    PdfPage page1 = section1.Pages.Add();
    //insert the section at specified index.
    document.Sections.Insert(0, section1);
    //Save the document.
    document.Save("Output.pdf");
    //Close the document.
    document.Close(true);
    'Create a new PDF document.
    Dim document As New PdfDocument()
    'Add the section.
    Dim section As PdfSection = document.Sections.Add()
    'Add pages to the section.
    Dim page As PdfPage = section.Pages.Add()
    'Add the section.
    Dim section1 As PdfSection = document.Sections.Add()
    'Add pages to the section1.
    Dim page1 As PdfPage = section1.Pages.Add()
    'insert the section at specified index.
    document.Sections.Insert(0, section1)
    'Save the document.
    document.Save("Output.pdf")
    'Close the document.
    document.Close(True)
    See Also
    PdfDocument
    PdfPage

    Implements

    System.Collections.IEnumerable

    See Also

    PdfDocument
    PdfPage
    PdfGraphics
    PdfFont
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved