Xamarin.Forms

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

    Show / Hide Table of Contents

    Class PdfSectionPageCollection

    Represents the collection of pages in a PdfSection .

    Inheritance
    System.Object
    PdfSectionPageCollection
    Implements
    System.Collections.IEnumerable
    Namespace: Syncfusion.Pdf
    Assembly: Syncfusion.Pdf.Portable.dll
    Syntax
    public class PdfSectionPageCollection : Object, IEnumerable
    Examples
    //Create a new PDF document.
    PdfDocument document = new PdfDocument();
    //Add the section.
    PdfSection section = document.Sections.Add();
    //Get the page collection from a section.
    PdfSectionPageCollection pageCollection = document.Sections[0].Pages;
    //Add the page.
    PdfPage page = pageCollection.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()
    'Get the page collection from a section.
    Dim pageCollection As PdfSectionPageCollection = document.Sections(0).Pages
    'Add the page.
    Dim page As PdfPage = pageCollection.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 count of the pages.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    System.Int32
    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();
    //Get the page count in a section.
    int count = document.Sections[0].Pages.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 the section.
    Dim section1 As PdfSection = document.Sections.Add()
    'Add pages to the section1.
    Dim page1 As PdfPage = section1.Pages.Add()
    'Get the page count in a section.
    Dim count As Integer = document.Sections(0).Pages.Count
    'Save the document.
    document.Save("Output.pdf")
    'Close the document.
    document.Close(True)
    See Also
    PdfDocument

    Item[Int32]

    Gets the PdfPage at the specified index.

    Declaration
    public PdfPage this[int index] { get; }
    Parameters
    Type Name Description
    System.Int32 index
    Property Value
    Type Description
    PdfPage
    Examples
    //Create a new PDF document.
    PdfDocument document = new PdfDocument();
    //Add the section.
    PdfSection section = document.Sections.Add();
    //Get the page collection from a section.
    PdfSectionPageCollection pageCollection = document.Sections[0].Pages;
    //Add the page.
    PdfPage page = pageCollection.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()
    'Get the page collection from a section.
    Dim pageCollection As PdfSectionPageCollection = document.Sections(0).Pages
    'Add the page.
    Dim page As PdfPage = pageCollection.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
    PdfFont
    PdfBrush

    Methods

    Add()

    Creates a new page and adds it into the collection.

    Declaration
    public PdfPage Add()
    Returns
    Type Description
    PdfPage

    The new page.

    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();
    //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 the section.
    Dim section1 As PdfSection = document.Sections.Add()
    'Add pages to the 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
    PdfFont
    PdfBrush

    Add(PdfPage)

    Adds a page into collection.

    Declaration
    public void Add(PdfPage page)
    Parameters
    Type Name Description
    PdfPage page

    The page.

    Examples
    //Create a new PDF document.
    PdfDocument document = new PdfDocument();
    //Add the section.
    PdfSection section = document.Sections.Add();
    //Create a new pdf page.
    PdfPage page = new PdfPage();
    //Add the page into section.
    document.Sections[0].Pages.Add(page);
    //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()
    'Create a new pdf page.
    Dim page As New PdfPage()
    'Add the page into section.
    document.Sections(0).Pages.Add(page)
    '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
    PdfFont
    PdfBrush

    Clear()

    Clears this collection.

    Declaration
    public void Clear()
    Examples
    //Create a new PDF document.
    PdfDocument document = new PdfDocument();
    //Add the section.
    PdfSection section = document.Sections.Add();
    //Add first page to the section.
    PdfPage page = section.Pages.Add();
    //Add second page to the section.
    PdfPage page1 = section.Pages.Add();
    //Clear all the pages from first section of pdf document.
    document.Sections[0].Pages.Clear();
    //Save the document.
    document.Save("Output.pdf");
    //Close the document.
    document.Close(true);
    'Create a new PDF document.
    Dim document As PdfDocument = New PdfDocument()
    'Add the section.
    Dim section As PdfSection = document.Sections.Add()
    'Add first page to the section.
    Dim page As PdfPage = section.Pages.Add()
    'Add second page to the section.
    Dim page1 As PdfPage = section.Pages.Add()
    'Clear all the pages from first section of pdf document.
    document.Sections(0).Pages.Clear()
    'Save and close the document.
    document.Save("Output.pdf")
    document.Close(True)

    Contains(PdfPage)

    Determines whether the specified page is within the collection.

    Declaration
    public bool Contains(PdfPage page)
    Parameters
    Type Name Description
    PdfPage page

    The PdfPage

    Returns
    Type Description
    System.Boolean

    true if the collection contains the specified page; otherwise, false.

    Examples
    //Create a new PDF document.
    PdfDocument document = new PdfDocument();
    //Add the section.
    PdfSection section = document.Sections.Add();
    //Add page to the section.
    PdfPage page = section.Pages.Add();
    //Add the section.
    PdfSection section1 = document.Sections.Add();
    //Add page to the section1.
    PdfPage page1 = section1.Pages.Add();
    //check whether the specified page is in collection.
    bool isExists = document.Sections[0].Pages.Contains(page1);
    //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 page to the section.
    Dim page As PdfPage = section.Pages.Add()
    'Add the section.
    Dim section1 As PdfSection = document.Sections.Add()
    'Add page to the section1.
    Dim page1 As PdfPage = section1.Pages.Add()
    'check whether the specified page is in collection.
    Dim isExists As Boolean = document.Sections(0).Pages.Contains(page1)
    'Save the document.
    document.Save("Output.pdf")
    'Close the document.
    document.Close(True)
    See Also
    PdfDocument

    IndexOf(PdfPage)

    Returns the index of the specified page.

    Declaration
    public int IndexOf(PdfPage page)
    Parameters
    Type Name Description
    PdfPage page

    The PdfPage

    Returns
    Type Description
    System.Int32

    Index of the page if the collection contains the specified page; otherwise, -1.

    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();
    //Create a page.
    PdfPage page1 = new PdfPage();
    //Get index of the page from Pdf section page collections.
    int index = document.Sections[0].Pages.IndexOf(page);
    //Save the document.
    document.Save("Output.pdf");
    //Close the document.
    document.Close(true);
    'Create a new PDF document.
    Dim document As PdfDocument = New PdfDocument()
    'Add the section.
    Dim section As PdfSection = document.Sections.Add()
    'Add pages to the section.
    Dim page As PdfPage = section.Pages.Add()
    'Create a page.
    Dim page1 As PdfPage = New PdfPage()
    'Get index of the page from Pdf section page collections.
    Dim index As Integer = document.Sections(0).Pages.IndexOf(page)
    'Save and close the document.
    document.Save("Output.pdf")
    document.Close(True)
    See Also
    PdfDocument

    Insert(Int32, PdfPage)

    Inserts a page at the specified index.

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

    The index of the page to be added.

    PdfPage page

    The page to be added.

    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();
    //Create a page.
    PdfPage page1 = new PdfPage();
    //Insert a page at specified index.
    document.Sections[0].Pages.Insert(0, page);
    //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()
    'Create a page.
    Dim page1 As New PdfPage()
    'Insert a page at specified index.
    document.Sections(0).Pages.Insert(0, page)
    'Save the document.
    document.Save("Output.pdf")
    'Close the document.
    document.Close(True)
    See Also
    PdfDocument

    Remove(PdfPage)

    Removes the specified page from collection.

    Declaration
    public void Remove(PdfPage page)
    Parameters
    Type Name Description
    PdfPage page

    The page.

    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();
    //Create a page.
    PdfPage page1 = section.Pages.Add();
    //Remove the page from Pdf section page collections.
    document.Sections[0].Pages.Remove(page);
    //Get page count, it will be one
    int count = document.Sections[0].Pages.Count;
    //Save the document.
    document.Save("Output.pdf");
    //Close the document.
    document.Close(true);
    'Create a new PDF document.
    Dim document As PdfDocument = New PdfDocument()
    'Add the section.
    Dim section As PdfSection = document.Sections.Add()
    'Add pages to the section.
    Dim page As PdfPage = section.Pages.Add()
    'Create a page.
    Dim page1 As PdfPage = section.Pages.Add()
    'Remove the page from Pdf section page collections.
    document.Sections(0).Pages.Remove(page)
    'Get page count, it will be one
    Dim count As Integer = document.Sections(0).Pages.Count
    'Save the document.
    document.Save("Output.pdf")
    'Close the document.
    document.Close(True)
    See Also
    PdfDocument

    RemoveAt(Int32)

    Removes a page at the specified index.

    Declaration
    public void RemoveAt(int index)
    Parameters
    Type Name Description
    System.Int32 index

    The index of the page to be removed.

    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();
    //Remove the page at specified index.
    document.Sections[0].Pages.RemoveAt(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 the section.
    Dim section1 As PdfSection = document.Sections.Add()
    'Add pages to the section1.
    Dim page1 As PdfPage = section1.Pages.Add()
    'Remove the page at specified index.
    document.Sections(0).Pages.RemoveAt(0)
    'Save the document.
    document.Save("Output.pdf")
    'Close the document.
    document.Close(True)
    See Also
    PdfDocument

    Implements

    System.Collections.IEnumerable

    See Also

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