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.
Note. Always use the latest version of iTextSharp.
After iTextSharp is installed in your Solution, check whether it exists or not, in your "References".
Create two new folders in your solution which will be used for saving the uploaded documents and splitting the PDF document.
Then, take a new page and design it like the below picture.
First, upload the file and click on Save.
I am saving the uploaded document in a folder called OriginalDoc.
And, in that same method, I am calling another method named as SplitPdf which has two parameters, SourcePath and filename without extension.
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.
And the SplitDoc folder looks like this.
Note
- 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.