Copy link to clipboard
Copied
CombinedPDF.InsertPages ALWAYS returns false and so throws Exception("could not insert pages")
what could be wrong here?
My visual studio 2015 project has reference set to
------------------------------
Adobe Acrobat 9.0 Type Library
------------------------------
found in
"C:\Program Files (x86)\Adobe\Acrobat 10.0\Acrobat\acrobat.tlb"
Private Sub CombinePDFs(PdfPaths As Specialized.StringCollection, MergedFileName As String)
Dim CombinedPDF As New Acrobat.AcroPDDoc '<--I have also tried late binding with no joy
Dim sourcepdf As New Acrobat.AcroPDDoc '<--I have also tried late binding with no joy
Try
If Not CombinedPDF.Create() Then
Throw New Exception("could not create merge file")
End If
--------------------------------
For Each s As String In PdfPaths
sourcepdf.Open(s)
If Not CombinedPDF.InsertPages(CombinedPDF.GetNumPages, sourcepdf, 0, sourcepdf.GetNumPages, False) Then
Throw New Exception("could not insert pages")
End If
sourcepdf.Close()
Next
--------------------------------
CombinedPDF.Save(1, mergedFileName)
CombinedPDF.Close()
Catch ex As Exception
MsgBox(ex.Message)
Finally
sourcepdf = Nothing
CombinedPDF = Nothing
End Try
End Sub
As I suspected in the last reply, the presence of Reader DC on the development machine was interfering with the reference to Acrobat 10(full version).
After uninstalling Reader DC, Insertpages finally worked as expected.
Copy link to clipboard
Copied
Refer to Insert Pages in New PDF
Copy link to clipboard
Copied
Tried with initial page parameter = 0 and initial page parameter = -1 but no joy.
Tried with a brand new PdDoc constructed by the CREATE method but no joy, also
Tried with a target PdDoc made up of a single cover page and inserting into it but no joy.
Tried using cAcroPDDoc interface instead of AcroPDDoc class but no joy.
I've tried so many variations on the call that I am coming around to thinking there is something about my visual studio/acrobat environment mismatch.
I have been manipulating documents with the IAC in my old VB6 environment without issues for 15 years,
but in vs 2015, neither early binding nor late binding is making any difference: insertpages method doesn't throw an error and doesn't insert pages, just returns false.
I have both Acrobat 10 and Reader DC installed on the development machine. The reference to the Type Library is coming from the Acrobat 10 program folder - Although it displays as 9.0 Type library in the references. I assume the type lib interface didn't change between versions so is not a problem. Is just having Reader DC installed causing problems?
Copy link to clipboard
Copied
As I suspected in the last reply, the presence of Reader DC on the development machine was interfering with the reference to Acrobat 10(full version).
After uninstalling Reader DC, Insertpages finally worked as expected.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more