Convert A Single PDF Into Number Of Pages As A PDF Using iTextSharp

For Example - I will upload a sample PDF which 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 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 spliting 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 filenamewithoutExtension.



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 into SplitDoc folder.

After the conversion is completed, the OriginalDoc folder looks like this.



And the SplitDoc folder looks like this.



Note

  1. Please add these "using" statements in your .cs file otherwise it will show you an error message.



  2. This is just a sample application and you can modify it as per your requirement.

Up Next
    Ebook Download
    View all
    Learn
    View all