using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SelectPdf;

namespace SelectPdf.Samples
{
    public partial class pdf_split : System.Web.UI.Page
    {
        protected void BtnCreatePdf_Click(object sender, EventArgs e)
        {
            // the initial file
            string file1 = Server.MapPath("~/files/doc.pdf");

            // load the pdf document
            PdfDocument doc1 = new PdfDocument(file1);

            // create a new pdf document
            PdfDocument doc = new PdfDocument();

            // add 2 pages to the new document
            if (doc1.Pages.Count > 2)
            {
                doc.AddPage(doc1.Pages[1]);
                doc.AddPage(doc1.Pages[2]);
            }

            // save pdf document
            doc.Save(Response, false, "Sample.pdf");

            // close pdf document
            doc.Close();

            // close the original pdf document
            doc1.Close();
        }
    }
}