Skip to main content
Participant
Jun 23, 2023 3:30 PM UTC
Question

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

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 is closed to new replies. Start a new post to keep the conversation going.

2 replies

Legend
Jun 23, 2023 4:17 PM UTC

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).

Translate
FirstApAuthor
Participant
Jun 23, 2023 4:33 PM UTC

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.

Translate