Click or drag to resize

Getting Started with ExpertPdf PDF Split Library for .NET. PDF pages extractor tool.

There are 2 ways to install ExpertPdf PdfSplit Library:

  • Using a NuGet package (.NET Framework and .NET Core)

  • Downloading assemblies

Installation using Nuget Packages

The easiest way to install ExpertPdf PdfPlit is by using a Nuget Package. Create your project, go to Nuget Package Manager and install one of the following packages:

.NET Framework and .NET Core version - AnyCPU - ExpertPdf.SplitPdf: https://www.nuget.org/packages/ExpertPdf.SplitPdf/.

.NET Framework and .NET Core version - x64 optimized version - ExpertPdf.SplitPdf.x64: https://www.nuget.org/packages/ExpertPdf.SplitPdf.x64/.

Note 1: If the x64 version is used, the application needs to target x64 platform and it needs to run in an x64 worker process.

Note 2: The .NET Core version is for .NET Core 2.0 or above through .NET Standard 2.0. Currently it requires a Windows system to run. It does not work on Linux or Mac or Xamarin.

Installation using Downloaded Assemblies

The ExpertPdf PDF Split Library for .NET can be used in any type of .NET application to split PDF documents or extract pages from PDF documents. Using the library customizations, you can extract a range of pages from the PDF document or you can split the document in sections of the desired length. The product archive contains the development libraries for .NET 2.0 or .NET 4.0 and a ready to use console application in the Samples folder (written in C# and VB.NET).

Here are the steps needed to get started working with the library referencing the assembly directly:

  1. Add epsplitpdf.dll to the bin folder of your application.

  2. Add a reference in the project to epsplitpdf.dll.

  3. Write your code (see the samples and the API reference for help).

PDF Split Development Library

The ExpertPdf PDF Split develoment library epsplitpdf.dll is a managed assembly that can be linked into any .NET application, either Windows Forms and console applications or ASP.NET 2.0/4.0 web sites. The interface is very easy to use and understand.

The main class in the assembly is PDFSplitManager. An instance of this class can be constructed by specifying the merged document options as an instance of the PdfDocumentOptions class or using the default document options (normal compression). If you need to change any of these settings you have to pass a PdfDocumentOptions object to the PDFSplitManager constructor. For a complete reference of the assembly classes and methods see the API section of this manual.

To start working with the PDF Splitter, you have to create an instance of the PDFSplitManager class and then call the split and extract methods. The PDFSplitManager class offers interfaces to split the document in chunks of the number of pages or extract a range of pages from the PDF document.

All the methods have versions working for the memory representation of the PDF document as an array of bytes or for PDF files.

The memory versions of the methods can be used to easily interface with the other PDF tools producing PDF documents in memory. The memory representation of a PDF document resulted after split is encapsulated by the PDFSplitDoc class. This class can be used to get the internal array of bytes or to save the PDF bytes into a file on the disk.

When you want to perform the split, you can simply call the methods like ExtractPagesFromFileToFile, ExtractPagesFromFileToMemory, ExtractPagesFromMemoryToFile or ExtractPagesFromMemoryToMemory to perform the split or extract. There is also a method which gives you the number of pages from the PDF document - GetPdfPageCount.

Code Sample

All the split process can be done in a few lines of code. You can specify if you want to repeat extracting document chunks until the end of the document is reached or to specify the number of chunks you want to extract.

PDFSplitManager splitManager = new PDFSplitManager();

if (repeatToEnd) {
    splitManager.ExtractPagesFromFileToFile(srcPdfFile, outFile, startPageNumber, splitPageCount, true);
}
else {
    splitManager.ExtractPagesFromFileToFile(srcPdfFile, outFile, startPageNumber, splitPageCount, repeatCount);
}
PDF Split Command Line Tool

The PDF Split Command Line Tool is a simple application constructed based on the development libraries. It is also a ready to use application in case you don't need to build your own application. The command line syntax is:

splitpdf.exe /pdf:source_pdf_file [/startpage:start_page_number] [/splitsize:split_page_count] [/repeatcount:repeat_count] /out:out_file

In simple terms this syntax means that you can specify the source pdf file, the page where you want to start splitting, the size in pages of a resulted chunk, the number of chunks you want to extract and the output file. By default, if no repeat count is specified, the tool will repeat extracting to the end of the document.

The out file is used to determine the path and the name of the extracted chunks. Each extracted chunk is written in a file containg the chunk index.

Command line example:

SplitPdf.exe /pdf:VSS_White_Paper.pdf /startpage:1 /splitsize:3 /out:splitout.pdf

Licensing

The LicenseKey property of the PDFSplitManager class should be set with the license key string you have received after the product purchase.