Skip to main content
Participant
June 23, 2023
Question

In VBA, using the Javascript SaveAs method on a PDF to save as a png or jpg doesn't work

  • June 23, 2023
  • 1 reply
  • 1338 views

I've recently started using the SDK with the interapplication communication documentation to work with PDF files through VBA (in this case, VBA through Excel).

 

Presently, I've been able to successfully write code that finds text on a page, sets the correct rectangle bounds around that text, and then crops the PDF to that area. However, when trying to use the Javascript "SaveAs" method, it doesn't work properly. My line of code reads:

JSO.SaveAs wbpath & "\IAR YtD.png", "com.adobe.acrobat.png"

Where "JSO" is the name of my Javascript Object and "wbpath" is the string variable containing the path of the excel workbook I'm working with.

 

The result from using it changes based on if I try to export a Jpg or a Png. As a png, it returns a "write error" saying there isn't enough disc space (when there is plenty). As a jpg, it completely crashes the entire Adobe Acrobat application.

 

What do I need to do to make saving the PDF file as an image work through VBA?

This topic has been closed for replies.

1 reply

Legend
June 23, 2023

Try turning off Protected Mode. It is designed to block the sort of things developer often want to do. (Preferences -> Security (enhanced); NB this is NOT the same as Protected View, don't mix them up).

FirstApAuthor
Participant
June 23, 2023

That fixed it, thanks! I thought I had changed the necessary security settings but somehow missed that one specifically, as I had only turned off the "Enable Advanced Security" feature.