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_merge
        Inherits System.Web.UI.Page

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

            ' load the 2 pdf documents
            Dim doc1 As New PdfDocument(file1)
            Dim doc2 As New PdfDocument(file2)

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

            ' add the pages of those 2 documents to the new document
            doc.Append(doc1)
            doc.Append(doc2)

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

            ' close pdf document
            doc.Close()

            ' close the original pdf documents
            doc1.Close()
            doc2.Close()
        End Sub
    End Class
End Namespace
