[Root] / Xceed.PdfLibrary.NET Assembly / Xceed.PdfLibrary.NET Namespace / SplitByPageOptions Class
Example
In This Topic
    SplitByPageOptions Class
    In This Topic
    Provides options for splitting a PDFDocument by Page numbers or Page ranges.
    Object Model
    SplitByPageOptions ClassSplitByPageOptions ClassSplitByPageOptions ClassSplitByPageOptions Class
    Syntax
    public class SplitByPageOptions : SplitOptions 
    Remarks
    This class supports three main splitting scenarios:
    • Extracting a single Page to a file or stream
    • Extracting a range of Pages to a single file or stream
    • Splitting all Pages individually, each to its own file or stream
    This means that the output can be directed to either file paths or streams. When splitting all Pages individually to files, the output filename is used as a base pattern, with "_Page_N" appended to each file. When using streams for individualPages, provide one stream per Page in the PdfDocument.

    Note that the Page indices are zero-based, which means that the first Page is found at index 0.

    Also note that you can use the static Factory Methods to create instances with specific configurations.

    Example
    // Extracts a single Page to a file
    var options = SplitByPageOptions.ToPath(2, "output/page3.pdf");
    document.Split(options);
    
    // Extracts a Page range to a stream
    using (var stream = new MemoryStream())
    {
      var options = SplitByPageOptions.ToStream(0, 4, stream);
      document.Split(options);
    }
    
    // Splits all Pages to separate files
    var options = SplitByPageOptions.ToPath("output/document.pdf");
    document.Split(options); // Creates document_Page_1.pdf, document_Page_2.pdf, etc.
    Inheritance Hierarchy

    System.Object
       Xceed.PdfLibrary.NET.SplitOptions
          Xceed.PdfLibrary.NET.SplitByPageOptions

    Public Properties
     NameDescription
    Public Property Gets the zero-based index corresponding to the first Page that will be extracted (inclusive).  
    Public Property Gets the filepath that will be used to save the output of the split operation. (Inherited from Xceed.PdfLibrary.NET.SplitOptions)
    Public Property The streams that will be used as output for the split PdfDocuments. (Inherited from Xceed.PdfLibrary.NET.SplitOptions)
    Public Property Gets the zero-based index corresponding to the last Page that will be extracted (inclusive).  
    Top
    Public Methods
     NameDescription
    Public Methodstatic (Shared in Visual Basic)Overloaded.  Creates the options that will be used to extract a single Page to a file.  
    Public Methodstatic (Shared in Visual Basic)Overloaded.  Splits a single Page to a stream.  
    Public Methodstatic (Shared in Visual Basic) Creates the options that will be used to split all Pages individually, with each Page written to its own stream.  
    Top
    Supported Frameworks

    .NET: net5.0, net5.0-windows, net6.0, net6.0-macos, net6.0-windows, net7.0, net7.0-macos, net7.0-windows, net8.0, net8.0-browser, net8.0-macos, net8.0-windows, net9.0, net9.0-browser, net9.0-macos, net9.0-windows, net10.0, net10.0-browser, net10.0-macos, net10.0-windows.

    .NET Framework: net40, net403, net45, net451, net452, net46, net461, net462, net463, net47, net471, net472, net48, net481.

    See Also