In the previous tutorial, you learnt how to write C# code to combine or merge many PDF files to become a single-page PDF file. It is a straight forward process. In some situations the reversing task can occur. For example, once a PDF file is too large, it is not easy to send this file via e-mail to your classmates or co-workers. So it must be split.
By using iTextSharp library, you can easily split a large PDF file into many single-page PDF files. You will have a PdfReader object to read the large file. Then create a new PdfCopy object for every page to split the document
into individual pages. You can reuse the same PdfReader object for different PdfCopy objects. The example C# code below will split the jmf_tutorial.pdf file to many single-page PDF files. The original file has 25 pages and its size is about 185KB. After spliting you will get 25 PDF files. Each PDF file has one page with a file size of about 101KB. By multiplying 25 by 101KB, you will get 2525KB which is greater than the original 185KB. This is because resources that were shared among pages in the original PDF file are now copied into each separate PDF file.
String result = "d:/result";
//create PdfReader object
PdfReader reader = new PdfReader(source_file);
for (int i = 1; i <=reader.NumberOfPages ; i++)
//create Document object
Document document = new Document();
copy = new PdfCopy(document, new FileStream(result+i+".pdf", FileMode.Create));
//open the document
//add page to PdfCopy
//close the document object
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages: