Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports SelectPdf

Namespace SelectPdf.Samples
    Partial Public Class pdf_split
        Inherits System.Web.UI.Page

        Protected Sub BtnCreatePdf_Click(sender As Object, e As EventArgs)
            ' the initial file
            Dim file1 As String = Server.MapPath("~/files/doc.pdf")

            ' load the pdf document
            Dim doc1 As New PdfDocument(file1)

            ' create a new pdf document
            Dim doc As New PdfDocument()

            ' add 2 pages to the new document
            If doc1.Pages.Count > 2 Then
                doc.AddPage(doc1.Pages(1))
                doc.AddPage(doc1.Pages(2))
            End If

            ' save pdf document
            doc.Save(Response, False, "Sample.pdf")

            ' close pdf document
            doc.Close()

            ' close the original pdf document
            doc1.Close()

        End Sub
    End Class
End Namespace
