Search Results:

Monday, November 2, 2009

Combine 2 PDF's Using vb.net

How To: Combine PDFs Using InsertPages



Issue
How do I combine multiple PDFs into one PDF using Visual Basic?
Solution
This record contains VisualBasic code to demonstrate AcroExch.PDDoc InsertPages.

As far as InsertPages is concerned, the tricky part is to remember that the page number you will be inserting after is -1; in other words, you want to insert these pages before page 0, which is the first page of the document.

Private Sub Command1_Click()
Dim b As Boolean

Dim AcroPDDoc As CAcroPDDoc
Dim PDDoc As CAcroPDDoc

Set AcroPDDoc = CreateObject("AcroExch.PDDoc")
Set PDDoc = CreateObject("AcroExch.PDDoc")

b = PDDoc.Open("c:\testinsertpages.pdf")
b = AcroPDDoc.Open("c:\Tips.pdf")
b = AcroPDDoc.InsertPages(0, PDDoc, 0, 1, False)
b = AcroPDDoc.Save(1, "c:\Tips.pdf")

End Sub

3 comments:

  1. Wow, that's difficult for many normal PDF users. I'm using this PDF Merger, I can combine PDFs into one PDF easily.

    ReplyDelete
    Replies
    1. Hi Melvin,

      I am telling about merging PDF's using VB.NET. If you have Acrobat you can merge PDF's using it.

      Delete
  2. iTextSharp is the best library you can use to work with PDF using c# or vb.net

    ReplyDelete