Skip to main content
September 26, 2017
Question

Problems createing a PDF file with multiple files using VB Script

  • September 26, 2017
  • 1 reply
  • 343 views

Bottom line up front I'm trying to create a PDF file by combining multiple file types ... PDF, PNG, JPG, HTML, TXT etc.. The code below creates a PDF file but it will only create a PDF file using PDF files. It completely ignores the PNG files.  Any help would be greatly appreciated.

Dim Doc1
Dim Doc2
Dim Doc3
Dim Doc4
Dim Doc5
Dim Doc6
Dim Doc7
Dim Doc8
Dim Doc9

Set Doc1 = CreateObject("AcroExch.PDDoc")
Set Doc2 = CreateObject("AcroExch.PDDoc")
Set Doc3 = CreateObject("AcroExch.PDDoc")
Set Doc4 = CreateObject("AcroExch.PDDoc")
Set Doc5 = CreateObject("AcroExch.PDDoc")
Set Doc6 = CreateObject("AcroExch.PDDoc")
Set Doc7 = CreateObject("AcroExch.PDDoc")
Set Doc8 = CreateObject("AcroExch.PDDoc")
Set Doc9 = CreateObject("AcroExch.PDDoc")

File1 = Doc1.Open("C:\Temp\Single_Page.pdf")
File2 = Doc2.Open("C:\Temp\Page-01.png")
File3 = Doc3.Open("C:\Temp\Page-21.png")
File4 = Doc4.Open("C:\Temp\Page-20.png")
File5 = Doc5.Open("C:\Temp\Page-19.png")
File6 = Doc6.Open("C:\Temp\Page-18.png")
File7 = Doc7.Open("C:\Temp\Page-17.png")
File8 = Doc8.Open("C:\Temp\Page-16.png")
File9 = Doc9.Open("C:\Temp\Page-15.png")

Stack = Doc1.InsertPages(Doc1.GetNumPages - 1, Doc2, 0, Doc2.GetNumPages, 0)
Stack = Doc1.InsertPages(Doc1.GetNumPages - 1, Doc3, 0, Doc3.GetNumPages, 0)
Stack = Doc1.InsertPages(Doc1.GetNumPages - 1, Doc4, 0, Doc4.GetNumPages, 0)
Stack = Doc1.InsertPages(Doc1.GetNumPages - 1, Doc5, 0, Doc5.GetNumPages, 0)
Stack = Doc1.InsertPages(Doc1.GetNumPages - 1, Doc6, 0, Doc6.GetNumPages, 0)
Stack = Doc1.InsertPages(Doc1.GetNumPages - 1, Doc7, 0, Doc7.GetNumPages, 0)
Stack = Doc1.InsertPages(Doc1.GetNumPages - 1, Doc8, 0, Doc8.GetNumPages, 0)
Stack = Doc1.InsertPages(Doc1.GetNumPages - 1, Doc9, 0, Doc9.GetNumPages, 0)

SaveStack = Doc1.Save(1,"C:\Temp\Output\Combined.PDF")

    This topic has been closed for replies.

    1 reply

    Legend
    September 26, 2017

    The PDDoc.Open method opens PDF files by definition. Further questions might be better sent to the Acrobat SDK forum as the script can't be for Acrobat Reader.