PDF Toolkit

Samples

Split PDF

Split PDF files

The PDFSplitter class provides different methods to split PDF files namely:

  • SplitByRepeatingNumber - Split PDF document with each split containing a particular number of pages
  • SplitByTopLevelBookmarks - Split the document by the top level bookmarks in the PDF.
  • SplitByPageRanges - Split PDF document by page ranges. E.g. 1, 3-7, 10
  • SplitByRepeatingPageRanges - Apply the page range to each set of "Page Ranges" pages within the document. For example if 2-4 is specified for page ranges, and 4 is specified as the repeating range, then the range is re-applied every 4 pages. Hence the file is split such that the first output file contains pages 2-4 from the original document; the second contains pages 6-8 and so on.

This Code sample requires the PDF Toolkit and is found in: C:\Aquaforest\PDF Toolkit\samples\SplitPDF

    
using Aquaforest.PDF;
namespace SplitPDF
{
    class Program
    {
        static void Main(string[] args)
        {
            PDFDocument doc = new PDFDocument(@"..\..\..\documents\source\cookbook.pdf");
            PDFSplitter splitter = new PDFSplitter(doc);
            splitter.OutputFileName = "split";
            splitter.OutputFilePath = @"..\..\..\documents\output\";
    
            splitter.SplitByRepeatingNumber(1, 5, 1);
        }
    }
}