• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

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

Community Beginner ,
Dec 17, 2019 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

TOPICS
Acrobat SDK and JavaScript

Views

2.9K

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
community guidelines

correct answers 1 Correct answer

Community Beginner , Dec 17, 2019 Dec 17, 2019

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 = AcroExchAV
...

Likes

Translate

Translate
Community Beginner ,
Dec 17, 2019 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
community guidelines
New Here ,
May 15, 2022 May 15, 2022

Copy link to clipboard

Copied

Hello, 

Thank you for this. I have been able to use it to creat a one page pdf. I am trying to create one PDF from multiple jpgs.  All I have been able to get is a PDF with multiple pages that all the same page. I am not sure how to establish a second of third AVDoc. Can you provide any insight?

 

Thanks in Advance,

George 

 

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
community guidelines
LEGEND ,
May 15, 2022 May 15, 2022

Copy link to clipboard

Copied

LATEST

To create a second AVDoc 

Set SecondAcroExchAVDoc = CreateObject("AcroExch.AVDoc")

 

By the way, if your files are fill-in forms, this is working as designed. Combining files with the same form field names gives multiple copies of form fields with the same name. By design, they will all have the same value. You cannot combine live forms and keep them separate.

 

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
community guidelines