For Example
I will upload a sample PDF that contains 10 pages and after the split, it will show 10 PDF files which will be saved in a folder.
iTextSharp is a .NET PDF Library and for conversion, we need to download it from the NuGet package, or from Package Manager Console, or from its website, or directly add it as a reference in our solution.
![.NET PDF Library]()
Note. Always use the latest version of iTextSharp.
After iTextSharp is installed in your Solution, check whether it exists or not, in your "References".
![iTextSharp]()
Create two new folders in your solution which will be used for saving the uploaded documents and splitting the PDF document.
![PDF document]()
Then, take a new page and design it like the below picture.
![Design]()
First, upload the file and click on Save.
I am saving the uploaded document in a folder called OriginalDoc.
![OriginalDoc]()
And, in that same method, I am calling another method named as SplitPdf which has two parameters, SourcePath and filename without extension.
![SplitPdf]()
In the SplitPdf method, I created an object of PdfReader which will read the document from SourcePath. In for loop, I am creating the individual PDF by using Document and PdfCopy and storing those new PDF files in the SplitDoc folder.
After the conversion is completed, the OriginalDoc folder looks like this.
![OriginalDoc folder]()
And the SplitDoc folder looks like this.
![SplitDoc folder]()
Note
![C#]()
- Please add these "using" statements in your .cs file otherwise it will show you an error message.
- This is just a sample application and you can modify it as per your requirement.