Combining PDFs Using Adobe Acrobat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello!
I've recently been updating some code that was originally written for AutoCAD 2004 to get it to run on AutoCAD 2021 and I've been running into some issues while trying to combine three PDFs using Adobe Acrobat.
The code was written to make three separate drawings, print them to PDF, add their locations to a list, and then use that list to combine them into a singular PDF.
The code is as follows:
FileCopy PDFpage(1), FinalPDF
Kill PDFpage(1)
If pages > 1 Then
Dim b As Boolean
Dim AcroPDDoc As Acrobat.CAcroPDDoc
Dim PDDoc As Acrobat.CAcroPDDoc
Set AcroPDDoc = CreateObject("AcroExch.PDDoc")
b = AcroPDDoc.Open(FinalPDF)
For i = 2 To 3
Set PDDoc = CreateObject("AcroExch.PDDoc")
b = PDDoc.Open(PDFpage(i))
b = AcroPDDoc.InsertPages(i - 2, PDDoc, 0, 1, False)
Sleep (500)
'b = AcroPDDoc.Save(1, FinalPDF)
b = AcroPDDoc.Save(PDSaveFull, FinalPDF)
PDDoc.Close
Set PDDoc = Nothing
Sleep (500)
Kill PDFpage(i)
Next i
AcroPDDoc.Close
Set AcroPDDoc = Nothing
End IfFinal PDF is the name of the file that I want to add the remaining two pages to.
From my understanding, this code is using the first entry of the list as the FinalPDF base file, then adding the second entry as first page and the third entry as the middle page, bumping the first list entry to the last page of the PDF.
Since everything has a boolean output, I've been able to see that lines 13 and 14 are setting b to True. The line that it has been throwing False at me is the AcroPDDoc.Save line (line 17). The original code had a 1 as the first entry, so I changed it to PDSaveFull, but that did not fix my problem.
I would appreciate any feedback or suggestions!