Search Results for

    Show / Hide Table of Contents

    Class PdfPagesCollection

    Manages the collection of pages within a PDF document. Supports iteration, addition, removal, and direct access to individual pages.

    Access this collection via Pages property. The collection provides full control over document structure including page manipulation.

    Example - Work with pages:

    var pdf = PdfDocument.FromFile("document.pdf");
    

    // Iterate pages: foreach (var page in pdf.Pages) Console.WriteLine($"Page {page.PageIndex}: {page.Width}x{page.Height}");

    // Access specific page: var firstPage = pdf.Pages[0]; var lastPage = pdf.Pages[pdf.PageCount - 1];

    // Remove page: pdf.Pages.RemoveAt(2); // Remove page 3

    // Get page count: int totalPages = pdf.Pages.Count;

    Inheritance
    System.Object
    PdfPagesCollection
    Implements
    IPdfPageCollection
    IronSoftware.Abstractions.Absolute.IDocumentPageCollection<IPdfPage>
    System.Collections.Generic.IReadOnlyCollection<IPdfPage>
    System.Collections.Generic.IEnumerable<IPdfPage>
    System.Collections.IEnumerable
    Namespace: IronPdf.Pages
    Assembly: IronPdf.dll
    Syntax
    public class PdfPagesCollection : ObservableCollection<IPdfPage>, IPdfPageCollection

    Working with PDF pages in IronPDF runs through PdfPagesCollection. It manages the collection of pages within a PDF document.

    PdfPagesCollection matters when an application needs to configure or invoke PDF pages from C# code. The class encapsulates the related options and behavior in a single object that is set up once and reused across render or processing calls. Typical scenarios include batch generation pipelines, templated document workflows, and integration with existing C# document services.

    To use PdfPagesCollection, instantiate or obtain it from the relevant entry point in the IronPDF C# API. Key methods include Add, Clear, GetHashCode, RefreshPages. Assign options or invoke methods on the instance to configure or perform the operation. The access PDF DOM object covers typical usage in C# end to end.

    using IronPdf;
    
    // Obtain PdfPagesCollection from the relevant entry point in the IronPDF API
    void Configure(PdfPagesCollection instance)
    {
        instance.Add();
    }

    For the broader workflow, see the add copy delete pages PDF guide in the IronPDF C# documentation. For broader context, the PDF pages portion of the IronPDF C# API contains related types that work with PdfPagesCollection directly. PdfPagesCollection instances inherit additional members from ObservableCollection<IPdfPage> that may be relevant in advanced scenarios. In application code, treat PdfPagesCollection as a configured object that is constructed once and reused across operations rather than instantiated per call. Configuration is generally idempotent: assigning the same property value twice has the same effect as assigning it once. For diagnostic purposes, inspect the relevant PdfPagesCollection property after each operation to confirm the configured state. See the constructors, properties, and methods tables below for the complete API surface of PdfPagesCollection. Application code typically obtains or instantiates a single PdfPagesCollection and shares it across multiple IronPDF operations rather than recreating it per call.

    Methods

    Add(PdfPage)

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

    Clear()

    Declaration
    public void Clear()

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    System.Int32

    RefreshPages()

    Declaration
    public void RefreshPages()

    Remove(IPdfPage)

    Declaration
    public bool Remove(IPdfPage item)
    Parameters
    Type Name Description
    IPdfPage item
    Returns
    Type Description
    System.Boolean

    Remove(PdfPage)

    Declaration
    public bool Remove(PdfPage item)
    Parameters
    Type Name Description
    PdfPage item
    Returns
    Type Description
    System.Boolean

    RemoveAt(Int32)

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

    Implements

    IPdfPageCollection
    IronSoftware.Abstractions.Absolute.IDocumentPageCollection<>
    System.Collections.Generic.IReadOnlyCollection<>
    System.Collections.Generic.IEnumerable<>
    System.Collections.IEnumerable

    See Also

    PdfPage
    Pages
    ☀
    ☾
    Downloads
    • Download with Nuget
    • Start for Free
    In This Article
    Back to top
    Install with Nuget