We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Splitting a big pdf by each page

Thread ID:





128955 Feb 17,2017 01:38 PM UTC Feb 28,2017 11:06 AM UTC ASP.NET MVC 3
Tags: PDF
Syress Sumartha
Asked On February 17, 2017 01:38 PM UTC

The following signature shall be provided "public static List SplitThatPDF(byte[] myFile)", how to do this ? (e.g. a document with 30 pages, shall be splitted into 30 single pages returning as List)

Surya Kumar [Syncfusion]
Replied On February 20, 2017 12:41 PM UTC

Hi Syress, 
We appreciate your interest towards Syncfusion products. 
We can split all the pages in a document and it can be stored in a list, We have attached code snippet for saving each page to list as individual PDF document. Please find the code snippet below 
            //Converting loaded file to Byte array 
            byte[] dataBytes = File.ReadAllBytes("loaded.pdf"); 
            //Saving individual pages as  PdfDocument 
            List<PdfDocument> seperatePDF = SeperateAsPDF(dataBytes); 
Code snippet for saving each page to list as individual PdfDocument: 
     public static List<PdfDocument> SeperateAsPDF(byte[] myFile) 
            //Load document. 
            PdfLoadedDocument loadedDocument = new PdfLoadedDocument(myFile); 
            List<PdfDocument> PdfList = new List<PdfDocument>(); 
            for(int i = 0; i < loadedDocument.Pages.Count; i++) 
                PdfDocument doc = new PdfDocument(); 
                doc.ImportPageRange(loadedDocument, i, i); 
            return PdfList; 
Essential PDF also allows to split the pages of an existing PDF document into multiple individual PDF documents. The following code snippet explains the same. 
             //Load document. 
            PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Output.pdf"); 
            //Sets pattern. 
            const string destFilePattern = "Output" + "{0}.pdf"; 
            //Split the pages into separate documents. 
            //close the document 
Please let us know if you need any further information regarding this. 
Surya Kumar. 

Syress Sumartha
Replied On February 27, 2017 11:16 AM UTC

The Return type should be List<byte[]> . Can you adjust this ?

Surya Kumar [Syncfusion]
Replied On February 28, 2017 11:06 AM UTC

Hi Syress,  
Thanks for your update.  
Please find the modified code snippet as you requested, please let us know if this satisfies your requirement. 
            //Converting loaded file to Byte array  
            byte[] dataBytes = File.ReadAllBytes("loaded.pdf");  
            //Saving individual pages as  PdfDocument  
            List<byte[]> seperatePDF = SeperateAsPDF(dataBytes);  
Code snippet for saving each page to list as individual Byte array:  
     public static List<byte[]> SeperateAsPDF(byte[] myFile)  
            //Load document.  
            PdfLoadedDocument loadedDocument = new PdfLoadedDocument(myFile);  
            List<PdfDocument> pdfBytes= new List<PdfDocument>();  
            for(int i = 0; i < loadedDocument.Pages.Count; i++)  
                MemoryStream stream = new MemoryStream(); 
                PdfDocument doc = new PdfDocument();  
                doc.ImportPageRange(loadedDocument, i, i);  
            return pdfBytes;  
Surya Kumar 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon