Link Search Menu Expand Document

Insert Pages to PDF - VB.NET

PDF SDK sample in VB.NET demonstrating ‘Insert Pages to PDF’

Imports Bytescout.PDF

Module Module1

    Sub Main()

        ' Open first document
        Dim document1 = New Document("document1.pdf")
        document1.RegistrationName = "demo"
        document1.RegistrationKey = "demo"

        ' Open second document
        Dim document2 = New Document("document2.pdf")
        document2.RegistrationName = "demo"
        document2.RegistrationKey = "demo"

        ' Page index to insert document
        Dim pageIndexToAdd As Int32 = 1

        ' Add pages from document2 to document1
        For i As Integer = 0 To document2.Pages.Count - 1
            document1.Pages.Insert(pageIndexToAdd, document2.Pages(i))
            pageIndexToAdd = pageIndexToAdd + 1

        ' Save merged document

        ' Open merged document in default PDF viewer application
        Dim processStartInfo As New ProcessStartInfo("MergedDocument.pdf")
        processStartInfo.UseShellExecute = True

    End Sub

End Module

Download Source Code (.zip)

Return to the previous page Explore PDF SDK