Adobe Acrobat Pro via COM

Get help with using AutoHotkey and its commands and hotkeys
toralf
Posts: 432
Joined: 27 Apr 2014, 21:08
Location: Germany

Adobe Acrobat Pro via COM

09 Mar 2015, 13:13

Has someone tried to automate Acrobat Pro via COM before?
Are there snippets you would be willing to share?

I have found some information here
http://help.adobe.com/livedocs/acrobat_ ... index.html
But do not know really where to start and what I'm looking for to get the following done.

What I basically want to do is reduce the files size of PDFs: Open thousands of PDFs (in different folders) and save them with the PDF Optimizer replacing the original to reduce their size. Either directly (open/save as) or via the Action Wizard.
For the largest 11 files I have done this manually and it reduced the overall size from 248 MB to 86 MB. The 4310 PDF files I'm looking at use 4.35 GB in total.
ciao
toralf
User avatar
Blackholyman
Posts: 1236
Joined: 29 Sep 2013, 22:57
Facebook: socialjsz
Google: +Jszapp
Location: Denmark
Contact:

Re: Adobe Acrobat Pro via COM

09 Mar 2015, 19:30

I have not done much with adobe Acrobat pro

But did a little, a time back, and remember I got some good info from this link http://help.adobe.com/livedocs/acrobat_ ... sible=true
look for :
    Acrobat Interapplication Communication
    Necessary C knowledge
    PDF Optimizer API

Example of opening and doing a simple save via COM:

Code: [Select all] [Expand] [Download] (Script.ahk)GeSHi © Codebox Plus



But I did not have the time to go over all of the info in your link, but

    AV_Layer
      AVDoc
        AVDocSaveParams
          _t_AVDocSaveParams

Will tell you more about the structure you need to pass togetter with the AVDoc object if you find a way to invoke the AVDocSaveOptimized method

Hope it helps
toralf
Posts: 432
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Adobe Acrobat Pro via COM

09 Mar 2015, 20:07

Thank you so much.
That should be enough to get me started.

Edit:
In the IAC I did not find a way to start the Optimizer. Somehow I would need to invoke a different API.

void AVDocSaveOptimized(AVDoc avDoc, const PDFOptParamsRec* pdfOptParams)

For which I could get the Params with

ASBool AVGetOptimizerParamsForPreset(ASText presetName, AVDoc avDoc, PDFOptParams pdfOptParams)

But I have not figured out how to call this API with the COM commands.
I'll try if I can get a menu item to execute via the IAC, or even to automate Acrobat via keyboard shortcuts.
ciao
toralf
toralf
Posts: 432
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Adobe Acrobat Pro via COM

10 Mar 2015, 14:54

Has someone worked with Acrobat via DllCall?
I can load Acrobat.dll and AdobePDFL.dll but when I try to call a method (e.g. AVAppBeginFullScreen) I get an error level of -4 (The specified function could not be found inside the DLL)
In which DLL file do I find the functions of the API?

At the end I need to use the method AVDocSaveOptimized, but since it seems to be more difficult to set up the parameters I wanted to start 'easy'... I can't even get started. *Frust*

Edit: The Acrobat folder contains 295 Dlls....
ciao
toralf
toralf
Posts: 432
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Adobe Acrobat Pro via COM

10 Mar 2015, 19:58

It's not possible to call optimization from outside of acrobat
https://forums.adobe.com/thread/301716?start=12

Only via a plugin.
ciao
toralf
toralf
Posts: 432
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Adobe Acrobat Pro via COM

11 Mar 2015, 07:38

This is what I came up with. Not nice, but it is working

Code: [Select all] [Expand] [Download] (Untitled.txt)GeSHi © Codebox Plus

ciao
toralf
toopy

Re: Adobe Acrobat Pro via COM

05 Sep 2015, 13:46

Can these COM commands also be used to start things on the toolbar in Acrobat Pro for example to open the merge pdf window? Because Adobe has not added hotkeys to start many of the toolbar tools. Once the tool windows are open they are in many cases straightforward to control with send key commands.
toopy

Re: Adobe Acrobat Pro via COM

20 Sep 2015, 11:38

I'm getting back to this question after having searched more and tried a few things. But I've only figured out how to start the Acrobat application itself with COM but I can't find a method to open any of the toolbar tools through COM. ImageSearch for the toolbar icon is a possibility but that method is sensitive to changes in resolution and other settings on different computers. I guess Adobe wanted to make it hard to automate Acrobat and sell more of the super expensive corporate tools instead. :(
User avatar
Blackholyman
Posts: 1236
Joined: 29 Sep 2013, 22:57
Facebook: socialjsz
Google: +Jszapp
Location: Denmark
Contact:

Re: Adobe Acrobat Pro via COM

20 Sep 2015, 13:46

@toopy

Don't need to use the toolbar buttons an example of how to combine two PDF documents and save the result as a new document

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



But if you wish to try and execute toolbar actions you can use MenuItemExecute() the hard part, in that, is that you need to know the name that adobe uses for the item you wish to execute

Example of showing the SaveAs dialog

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Hope it helps
User avatar
tank
Posts: 2165
Joined: 28 Sep 2013, 22:15
Facebook: charlie.simmons.7334
Google: ttnnkkrr
GitHub: ttnnkkrr
Location: Louisville KY
Contact:

Re: Adobe Acrobat Pro via COM

20 Sep 2015, 13:59

Super that this is so current and relevant to a current project where combining pdf documents is going to be necessary
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
https://www.facebook.com/ahkscript.org
If you have forum suggestions please submit a pull request
toopy

Re: Adobe Acrobat Pro via COM

20 Sep 2015, 16:52

Thank you very much Blackholyman for that code snippet, it helped a lot.

Blackholyman wrote:But if you wish to try and execute toolbar actions you can use MenuItemExecute() the hard part, in that, is that you need to know the name that adobe uses for the item you wish to execute

Yes I'd also like to start the window for "Text recognition in multiple files" and "Text recognition in this file". Once the windows are open it is easy to automate then by sending keys. Any idea what the names for those command could be?
User avatar
Blackholyman
Posts: 1236
Joined: 29 Sep 2013, 22:57
Facebook: socialjsz
Google: +Jszapp
Location: Denmark
Contact:

Re: Adobe Acrobat Pro via COM

20 Sep 2015, 17:22

@Tank
Absolutely :)

@toopy
Know of one you can try oAcrobat.MenuItemExecute("Cpt:CapturePages")
toopy

Re: Adobe Acrobat Pro via COM

21 Sep 2015, 03:54

Blackholyman wrote: Know of one you can try oAcrobat.MenuItemExecute("Cpt:CapturePages")

Did not work in Acrobat XI Pro I'm afraid. I could be because there is no entry in the menu to start the "Text recognition in multiple files" and "Text recognition in this file" dialogs. Those can only be started from a toolbar icon or from the tools sidebar. Is there some command similar to MenuItemExecute to run stuff like that?
User avatar
Blackholyman
Posts: 1236
Joined: 29 Sep 2013, 22:57
Facebook: socialjsz
Google: +Jszapp
Location: Denmark
Contact:

Re: Adobe Acrobat Pro via COM

21 Sep 2015, 03:58

Not that I know of the top of my head sorry...
toopy

Re: Adobe Acrobat Pro via COM

25 Sep 2015, 06:07

Blackholyman wrote:Not that I know of the top of my head sorry...

I searched for som Acrobat SDK/API/etc documentation of what commands are available but came up empty. Does anyone have a full list of commands? Another possibility I've thought about is doing PostMessage type of commands but I'm not sure if that would work with Acrobat. What is the currently best tool to spy what such messages an application uses?

Return to “Ask For Help”

Who is online

Users browsing this forum: A_User, SVN and 47 guests