0 Replies Latest reply on Nov 3, 2009 6:19 AM by ManojBavikati

    PDF is not Merging. Please help me

    ManojBavikati Level 1

      Hi  I have a windows applicatoin which is developed using vb.net and i am trying to Attach or Combine 2 pdf's into one . It works for once or twice and after that it will not attach any pdf . The first pdf stays as such.

       

      The vb.net code is below. Please help me what was causing the problem and any possible solution.

       

      Code:

       

      Dim

       

      sFileName As String = ""

      sFileName =

      "doc1.pdf"

      FileCopy(sFileName,

      "Temp.pdf")

       

       

       

      Me.wbReport.Navigate("Temp.pdf")

       

       

       

      'Get File Name

       

       

      Dim sFileAttach As String = ""

       

       

      With Me.OpenFileDialog1

      .DefaultExt =

       

      "PDF"

      .Multiselect =

      False

      .Title =

      "Select file to attach"

      .FileName =

      ""

      .Filter =

      "Adobe PDF Files (*.pdf)|*.pdf"

      .ShowDialog()

      sFileAttach = .FileName

       

       

      End With

       

       

       

      If sFileAttach = "" Then

       

       

       

       

       

      Exit Sub

       

       

       

      End If

       

       

       

      Dim AcroApp As Object = CreateObject("AcroExch.App")

      ' ACRODISTXLib.PdfDistiller6

       

       

      Dim InsertPDDoc As Object = CreateObject("AcroExch.PDDoc")

       

       

       

      Dim RptPDDoc As Object = CreateObject("AcroExch.PDDoc")

       

       

      Try

      RptPDDoc.InsertPages(

      CType(RptPDDoc.GetNumPages, Integer) - 1, InsertPDDoc, 0, CType(InsertPDDoc.GetNumPages, Integer), False)

       

       

      Catch ex As

      Exception

      MsgBox(

       

      "Error Attaching Documents. Documents were not attached.")

       

       

       

      End Try

       

      Nothing

      InsertPDDoc =

      Nothing

       

       

       

       

      Me.wbReport.Navigate(sFileName)

       

      Any Suggestions ????

       

      Thanks in Advance for the help.

      RptPDDoc.Save(1, sFileName)

      RptPDDoc.Close()

      AcroApp.Exit()

      RptPDDoc =

      InsertPDDoc.Close()

       

      AcroApp.Hide()

      RptPDDoc.Open(sFileName)

      InsertPDDoc.Open(sFileAttach)