VBA: Printing an Image to PDF and/or Create PDF from file

Community Beginner ,
Dec 17, 2019

Copy link to clipboard

Copied

Hello,

I am trying to implement a prototype that is able to take a list of image files in Excel and print/convert these files to PDF.

 

I believe there may be some possibilities to how to implment this and am asking if anyone knows if they are practical:

  1. Is it possible to use the Adobe VBA SDK to access the "Create - > PDF from file" that is available from the file menu of adobe
  2. Is it possible to use the print shell command to print the file and automaticly select the "Adobe PDF" printer.
  3. Is it possible to use a shell command to access the "Adobe PDF" printer or Adobe Acrobat 2017 app directly to print the image file.

 

Win 10

Adobe Acrobat 2017 (pro)

 

Regards,

Daniel

I was able to determine a solution to this problem myself.

Turns out you can just open up an image file using an AVDoc object, getting the PDDoc Object from that and then using the PDDoc save method to save it to one's desired destination.

I will include a code snippet for anyone in the future.

 

Set AcroExchApp = CreateObject("AcroExch.App")
Set AcroExchAVDoc = CreateObject("AcroExch.AVDoc")
Set AcroExchPDDoc = CreateObject("AcroExch.PDDoc")
        
' Open the [Filename] pdf file
resp = AcroExchAVDoc.Open(filePath, "")

'Get the PDDoc associated with the open AVDoc    
Set AcroExchPDDoc = AcroExchAVDoc.GetPDDoc
        
'PDSaveFull = 1
resp = AcroExchPDDoc.Save(1, newFilename)
AcroExchApp.Exit
AcroExchAVDoc.Close (True)
AcroExchPDDoc.Close

 




TOPICS
Acrobat SDK and JavaScript, Create PDFs, Print and prepress

Views

1.0K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

VBA: Printing an Image to PDF and/or Create PDF from file

Community Beginner ,
Dec 17, 2019

Copy link to clipboard

Copied

Hello,

I am trying to implement a prototype that is able to take a list of image files in Excel and print/convert these files to PDF.

 

I believe there may be some possibilities to how to implment this and am asking if anyone knows if they are practical:

  1. Is it possible to use the Adobe VBA SDK to access the "Create - > PDF from file" that is available from the file menu of adobe
  2. Is it possible to use the print shell command to print the file and automaticly select the "Adobe PDF" printer.
  3. Is it possible to use a shell command to access the "Adobe PDF" printer or Adobe Acrobat 2017 app directly to print the image file.

 

Win 10

Adobe Acrobat 2017 (pro)

 

Regards,

Daniel

I was able to determine a solution to this problem myself.

Turns out you can just open up an image file using an AVDoc object, getting the PDDoc Object from that and then using the PDDoc save method to save it to one's desired destination.

I will include a code snippet for anyone in the future.

 

Set AcroExchApp = CreateObject("AcroExch.App")
Set AcroExchAVDoc = CreateObject("AcroExch.AVDoc")
Set AcroExchPDDoc = CreateObject("AcroExch.PDDoc")
        
' Open the [Filename] pdf file
resp = AcroExchAVDoc.Open(filePath, "")

'Get the PDDoc associated with the open AVDoc    
Set AcroExchPDDoc = AcroExchAVDoc.GetPDDoc
        
'PDSaveFull = 1
resp = AcroExchPDDoc.Save(1, newFilename)
AcroExchApp.Exit
AcroExchAVDoc.Close (True)
AcroExchPDDoc.Close

 




TOPICS
Acrobat SDK and JavaScript, Create PDFs, Print and prepress

Views

1.0K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 17, 2019 0
Community Beginner ,
Dec 17, 2019

Copy link to clipboard

Copied

I was able to determine a solution to this problem myself.

Turns out you can just open up an image file using an AVDoc object, getting the PDDoc Object from that and then using the PDDoc save method to save it to one's desired destination.

I will include a code snippet for anyone in the future.

 

Set AcroExchApp = CreateObject("AcroExch.App")
Set AcroExchAVDoc = CreateObject("AcroExch.AVDoc")
Set AcroExchPDDoc = CreateObject("AcroExch.PDDoc")
        
' Open the [Filename] pdf file
resp = AcroExchAVDoc.Open(filePath, "")

'Get the PDDoc associated with the open AVDoc    
Set AcroExchPDDoc = AcroExchAVDoc.GetPDDoc
        
'PDSaveFull = 1
resp = AcroExchPDDoc.Save(1, newFilename)
AcroExchApp.Exit
AcroExchAVDoc.Close (True)
AcroExchPDDoc.Close

 




Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 17, 2019 0