Click or drag to resize
Pdf Library for .NET

PdfSplitManager Class

Splits an existing PDF document: extracts pages into a new document, or divides it into several documents by page count, at its top level bookmarks or by file size.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfSplitManager

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.6
Syntax
public class PdfSplitManager : IDisposable

The PdfSplitManager type exposes the following members.

Constructors
 NameDescription
Public methodPdfSplitManagerInitializes a new instance of the PdfSplitManager class.
Top
Methods
 NameDescription
Public methodCloseReleases the loaded document.
Public methodDisposeReleases the loaded document; the same as Close.
Public methodExtractEvenPagesExtracts the even pages (the second, fourth, ...) into a new document.
Public methodExtractOddPagesExtracts the odd pages (the first, third, fifth, ...) into a new document.
Public methodExtractPagesExtracts pages into a new document, in the order given.
Public methodLoad(Byte)Loads a PDF document from a byte array.
Public methodLoad(PdfDocument)Loads an existing PdfDocument.
Public methodLoad(Stream)Loads a PDF document from a stream.
Public methodLoad(String)Loads a PDF document from a file.
Public methodLoad(Byte, String)Loads a password-protected PDF document from a byte array.
Public methodLoad(PdfDocument, String)Loads an existing PdfDocument with a password.
Public methodLoad(Stream, String)Loads a password-protected PDF document from a stream.
Public methodLoad(String, String)Loads a password-protected PDF document from a file.
Public methodSplitDivides the document into documents of at most pagesPerDocument pages each.
Public methodSplitByBookmarks Divides the document at its top level bookmarks: one document per bookmark, from the page it opens to the page before the next one, titled with the bookmark's text.
Public methodSplitBySize Divides the document into documents of at most maxFileSize bytes each, every one holding as many pages as fit.
Top
Remarks
Load a document with one of the Load overloads, then call the operations - each returns new PdfDocument objects, which can be changed further and must be saved and closed by the caller. The source document is not modified. Each extracted document keeps the source's document information, and the bookmarks and form fields of its pages; the logical structure and a PDF/A or PDF/UA claim are not carried.
Example
PdfSplitManager splitter = new PdfSplitManager();
splitter.Load("document.pdf");
PdfDocument summary = splitter.ExtractPages("1,3-5");
summary.Save("summary.pdf");
summary.Close();
PdfDocument[] parts = splitter.Split(10);
for (int i = 0; i < parts.Length; i++)
{
    parts[i].Save("part-" + (i + 1) + ".pdf");
    parts[i].Close();
}
splitter.Close();
See Also