public void SplitDocumentTest()
        {
            MemoryStream readerStream = TestHelper.ReadTestFileToMemory();
             PdfReader reader = new PdfReader(readerStream);
             PdfSplit newDoc = new PdfSplit();
             newDoc.StartPage = 3;
             newDoc.EndPage = 4;
             Document pdf = new Document(reader.GetPageSize(3));
             newDoc.SetPdfDocument(pdf);

             MemoryStream writerStream = new MemoryStream();

             PdfWriter writer = PdfWriter.GetInstance(pdf, writerStream);
             newDoc.Writer = writer;
             Assert.AreEqual(0, writerStream.Length);

             newDoc.OpenPdfDocument();

             newDoc.SplitDocument(reader);

             Assert.IsTrue(writerStream.Length > 0);
             newDoc.ClosePdfDocument();
        }
        /// <summary>
        /// Setups the child Pdfs with the information necessary to do the splits.
        /// </summary>
        public void SetupChildPdfs()
        {
            ArrayList bookmarks = SimpleBookmark.GetBookmark(Reader);
             IList<IPdfSplit> childPdfs = new List<IPdfSplit>();
             string destinationFolder = ConfigurationManager.AppSettings["Destination Folder"];
             int sequence = 1;
             foreach (Hashtable bookmark in bookmarks)
             {
            IPdfSplit child = new PdfSplit();

            string page = bookmark["Page"].ToString();
            int startPage = GetPageNumberFromBookmark(page);
            child.StartPage = startPage;
            child.BookmarkName = bookmark["Title"].ToString();
            child.SequenceNumber = sequence++;
            child.FileName = GetChildFileName(FileName, child.BookmarkName, child.SequenceNumber);
            child.DestinationPath = destinationFolder;
            Document newDoc = new Document(Reader.GetPageSizeWithRotation(startPage));
            child.SetPdfDocument(newDoc);
            childPdfs.Add(child);
             }

             // find ending page for each document
             int lastPage = Reader.NumberOfPages;
             for (int i = childPdfs.Count - 1; i >= 0; i--)
             {
            IPdfSplit child = childPdfs[i];
            child.EndPage = lastPage;
            lastPage = child.StartPage - 1;
             }

             SplitDocuments = childPdfs;
        }