XDoc.PDF
Features
Tech Specs
How-to C#
How-to VB.NET
Pricing
C# PDF: How to PDF Create PDF Export File and Page Process PDF Read PDF Write Form Process Document Protect Annotation & Drawing PDF Print WPF Viewer & Editor Work with Other SDKs Barcode Read Barcode Create OCR Twain
File: Split PDF Document
  |  
Home ›› XDoc.PDF ›› C# PDF: Split PDF

How to split, cut Adobe PDF pages into multiple PDF files using XDoc.PDF for .NET library in C#, ASP.NET, Winforms


High quality PDF document splitter and cutter: full C# souce code to split PDF document apart in Visual C#.NET Application. Online Free Trial Download.




Best .NET PDF SDK control for splitting PDF document in Visual C# .NET project


High quality PDF separator and breaker component for integration and splitting PDF file in both .NET WinForm console application and ASP.NET project


C#.NET class source code for splitting PDF document in multiple methods in Visual Studio .NET program


Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint


Able to split PDF document in preview on webpage in ASP.NET


C# PDF splitter & cutter library for breaking PDF file into two or multiple files in .NET framework


Support to break a large PDF file into smaller files


Separate PDF file into single ones with defined pages


Divide PDF file into multiple files by outputting PDF file size


Split PDF document by PDF bookmark and outlines



C# PDF document splitting library control, XDoc.PDF, provides an advanced C# programming way to split PDF document into smaller PDF files in .NET developing applications. Using this C#.NET PDF document splitting library control, C# developers can easily and accurately disassemble multi-page PDF document into two or more separate PDF document files by page(s).


RasterEdge Visual C# .NET PDF document splitter control toolkit SDK can not only offer C# developers a professional .NET solution to split PDF document file but also provide them the ability to name outputted PDF document files with a customized name pattern using a few lines of simple Visual C# code.


This C#.NET PDF document splitting library control offers developers an efficient PDF document splitting approach, using which C# developers can split target PDF document file by specifying a page or pages. If needed, developers can also combine generated split PDF document files with other PDF files to form a new PDF file using RasterEdge XDoc.PDF. Besides, in the process of splitting PDF document, developers can also remove certain PDF page from target PDF file using C#.NET PDF page deletion API.


Please note, PDF file will be divided from the previous page of your defined page number which starts from 0. For example, your original PDF file contains 4 pages. If your page number is set as 1, then the two output PDF files will contains the first page and the later three pages respectively.





C#: quick to break, divide pdf document into multiple pdf files


Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging.Basic' or any other assembly or one of its dependencies. An attempt to load a program with an incorrect format", please check your configure as follows:

       

       If you are using x64 libraries/dlls, Right click the project -> Properties -> Build -> Platform target: x64.

       

       If using x86, the platform target should be x86.




        #region quick to split pdf document into multiple pdf files
        internal static void splitPdfFile()
        {
            String inputFilePath = @"C:\source.pdf";
            //Page indexes to devide pdf document
            int[] pageIndexes = new int[] { 2, 3 };
            String firstFile = @"C:\part_1.pdf";
            String secondFile = @"C:\part_2.pdf";
            String thirdFile = @"C:\part_3.pdf";
            //Split input file to 3 files.
            //File 0: page 0 ~ 1
            //File 1: page 2
            //File 2: page 3 ~
            String[] outputFiles = new String[] { firstFile, secondFile, thirdFile };
            PDFDocument.SplitDocument(inputFilePath, pageIndexes, outputFiles);
        }
        #endregion




C# split, divide PDF document by number of pages





        #region Split PDF document by number of pages
        internal static void splitPdfFileByPageNumber()
        {
            String inputFilePath = @"C:\1.pdf";

            //  set split option
            SplitOptions options = new SplitOptions(SplitMode.ByPage);
            //  limit the pages of each file to 8 pages
            options.MaxPages = 8;
            //  set output option
            SplitOutputOptions outputOps = new SplitOutputOptions();
            outputOps.OutputFolder = @"C:\output\";
            outputOps.Mode = 2;
            outputOps.Label = @"Part";
            outputOps.Separator = '_';
            //  split a PDF file with options
            PDFDocument.SplitDocument(inputFilePath, options, outputOps);
        }
        #endregion




C# cut, break pdf file by output file size





        #region split pdf file by output file size
        internal static void splitPdfFileBySize()
        {
            String inputFilePath = @"C:\1.pdf";
            //set split option.
            SplitOptions options = new SplitOptions(SplitMode.BySize);
            //limit the size of each file to 0.03M.
            options.MaxSize = 0.03F;
            //set output option.
            SplitOutputOptions outputOps = new SplitOutputOptions();
            outputOps.OutputFolder = @"C:\output\";
            outputOps.Mode = 1;
            outputOps.Label = @"splitByFileSizePart";
            outputOps.Separator = '_';
            //split a PDF file with options.
            PDFDocument.SplitDocument(inputFilePath, options, outputOps);
        }
        #endregion




C# split, divide pdf file by top level bookmarks





        #region split pdf file by top level bookmarks
        internal static void splitPdfFileByBookmarks()
        {
            String inputFilePath = @"C:\2.pdf";

            //  set split option
            SplitOptions options = new SplitOptions(SplitMode.ByBookMark);
            //  set output option
            SplitOutputOptions outputOps = new SplitOutputOptions();
            outputOps.OutputFolder = @"C:\output\";
            outputOps.Mode = 2;
            outputOps.Label = @"Part";
            outputOps.Separator = '_';
            //  split a PDF file with options
            PDFDocument.SplitDocument(inputFilePath, options, outputOps);
        }
        #endregion




.NET Class Namespace Required



In order to run the sample code, the following steps would be necessary.


Add necessary references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XImage.Raster.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XDoc.PDF.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.PDF;





public static void SplitDocument(String inputFilePath, SplitOptions splitOp, SplitOutputOptions outputOps)

Description:
     Split PDF file according to the specified settings by split options.

Parameters:



public static void SplitDocument(String source, int splitIndex, Stream[] streams)

Description:
     Split the source PDF file according to specified page index and save them into streams.

Parameters:



public static void SplitDocument(String source, int splitIndex, String[] fileName)

Description:
     Split the source PDF file according to specified page index and save them into files on the disk.

Parameters:



public static void SplitDocument(Stream source, int splitIndex, Stream[] streams)

Description:
     Split the source PDF stream according to specified page index and save them into streams.

Parameters:



public static void SplitDocument(Stream source, int splitIndex, String[] fileName)

Description:
     Split the source PDF stream according to specified page index and save them into files on the disk.

Parameters:



public static void SplitDocument(String inputFilePath, int[] splitIndexes, Stream[] outputStreams)

Description:
     Split the source PDF file into PDF files and save them into streams.

Parameters:



public static void SplitDocument(String inputFilePath, int[] splitIndexes, String[] outputFilePaths)

Description:
     Split the source PDF file into PDF files and save them into files on the disk.

Parameters:



public static void SplitDocument(Stream inputStream, int[] splitIndexes, Stream[] outputStreams)

Description:
     Split the source PDF stream according specified page indexes and save them into streams.

Parameters:



public static void SplitDocument(Stream inputStream, int[] splitIndexes, String[] outputFilePaths)

Description:
     Split the source PDF stream according specified page indexes and save them into files on the disk.

Parameters: