Accusoft.PdfXpress5.Net
Split a PDF Document into Multiple PDFs
See Also Send Feedback
PDF Xpress 5 for .NET - User Guide > How To > Modify PDF Document Content > Split a PDF Document into Multiple PDFs

Glossary Item Box

PDF Xpress™ supports splitting a source PDF document into multiple PDF documents using the InsertPages method.

C# Example Copy Code
// This code demonstrates splitting a source PDF into multiple PDFs 
Accusoft.PdfXpressSdk.PdfXpress  pdfXpress1 = null;
Document document = null;
Document doc_new = null;
InsertPagesOptions io = null;
OpenOptions oo = null;
PageList pageList = null;
PageRange pageRange = null;
Accusoft.PdfXpressSdk.SaveOptions so = null;
try
{
      pdfXpress1 = new PdfXpress();            
      pdfXpress1.Initialize(null,null);
      oo = new OpenOptions();
      oo.Filename = "C:\\multipage.pdf";
      document = new Document(pdfXpress1, oo);
      io = new InsertPagesOptions();
      io.SourceDocument = document;
      int pageCount = document.PageCount;
      pageList = new PageList();
      pageRange = new PageRange();
      pageList.Add(pageRange);
      io.PageList = pageList;
      so = new   SaveOptions();
      //Loop through each page and save it into a new file each time
      for (int a = 0; a < pageCount; a++)
      {
         io.InsertAtPageNumber  = 0;
         pageRange.StartPageNumber = a;
         pageRange.PageCount = 1;
         doc_new = new Document(pdfXpress1);
         doc_new.InsertPages(io);
         so.Filename = "C:\\split"+ a +".pdf" ;
         doc_new.Save(so);
       }
}
catch (System.Exception ex)
{
}
finally
{
      if ( null != so ) so.Dispose( );
      if ( null != pageRange) pageRange.Dispose( );
      if ( null != pageList ) pageList.Dispose( );
      if ( null != io ) io.Dispose( );
      if ( null != document ) document.Dispose( );
      if ( null != doc_new ) doc_new.Dispose( );
      if ( null != pdfXpress1 ) pdfXpress1.Dispose( );
}

 

See Also

©2012. Accusoft Corporation. All Rights Reserved.