Adobe Acrobat Pro via COM

Get help with using AutoHotkey and its commands and hotkeys
toralf
Posts: 488
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: 1268
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: 488
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: 488
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
User avatar
Blackholyman
Posts: 1268
Joined: 29 Sep 2013, 22:57
Facebook: socialjsz
Google: +Jszapp
Location: Denmark
Contact:

Re: Adobe Acrobat Pro via COM

10 Mar 2015, 17:47

can't say much :( this may have something http://www.postseek.com/result/?query=a ... eoptimized
toralf
Posts: 488
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: 488
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: 1268
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: 2328
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: 1268
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: 1268
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?
MannyKSoSo
Posts: 197
Joined: 28 Apr 2018, 21:59

Re: Adobe Acrobat Pro via COM

12 Jun 2018, 12:42

http://www.planetpdf.com/forumarchive/40476.asp --> I Found this link with a bunch of them, but I cannot prove that they work.

Still on the topic, I had a question about the https://help.adobe.com/en_US/acrobat/ac ... rhsyns=%20
I have tried to make a com object but for some reason I keep coming up with that it doesn't know the command.


Original by Blackholyman

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



Any thoughts?
FanaticGuru
Posts: 1164
Joined: 30 Sep 2013, 22:25

Re: Adobe Acrobat Pro via COM

12 Jun 2018, 16:30

toopy wrote:
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?

Here is an example for MenuItemExecute that I use often.

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

App := ComObjCreate("AcroExch.App")
App.Show()
App.MenuItemExecute("ImageConversion:Clipboard")
App.MenuItemExecute("SaveAs")
It converts an image on the clipboard to a PDF and then opens a SaveAs dialog to save the new PDF.

Here is a list of menu commands:

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

/*
[cName:File, oChildren:[[cName:Open],[cName:endOpenGroup],[cName:NewDocument, oChildren:[[cName:NewDocFromFile],[cName:ScanMenu, oChildren:[[cName:ScanPreset5],[cName:ScanPreset1],[cName:ScanPreset2],[cName:ScanPreset3],[cName:ScanPreset4],[cName:],[cName:Scan],[cName:],[cName:ScanConfigurePreset]]],[cName:Web2PDF:OpnURL],[cName:ImageConversion:Clipboard],[cName:],[cName:NewDocCombineFiles],[cName:CreateMultiplePDFFiles],[cName:],[cName:AcroForm:Forms_CreateNewForm],[cName:endCreatePDFGroup],[cName:NewDocCreateCollection]]],[cName:],[cName:Save],[cName:SaveAs],[cName:SaveAsSubmenu, oChildren:[[cName:ReduceFileSize],[cName:DIGSIG:SaveAndAuthenticate],[cName:SaveAsExtendedSubmenu, oChildren:[[cName:DIGSIG:UBDoc]]],[cName:PDFOptimizer]]],[cName:endSaveGroup],[cName:Email],[cName:SPAObject 50],[cName:SPAObject 51],[cName:],[cName:],[cName:],[cName:Revert],[cName:Close],[cName:endFormDataGroup],[cName:GeneralInfo],[cName:endDocInfoGroup],[cName:Print],[cName:endPrintGroup],[cName:SPAObject 46],[cName:SPAObject 47],[cName:RecentFile1],[cName:endRecentFileGroup],[cName:Quit]]],[cName:Edit, oChildren:[[cName:Undo],[cName:Redo],[cName:endUndoGroup],[cName:Cut],[cName:Copy],[cName:Paste],[cName:Clear],[cName:endEditGroup],[cName:SelectAll],[cName:DeselectAll],[cName:endSelectGroup],[cName:CopyFileToClipboard],[cName:endOleGroup],[cName:TouchUp:EditDocument],[cName:],[cName:SelectGraphics],[cName:],[cName:Spelling:Spelling, oChildren:[[cName:Spelling:Check Spelling],[cName:Spelling:Edit Dictionary]]],[cName:LookUpWord],[cName:endLookUpGroup],[cName:Find],[cName:FindSearch],[cName:endFindGroup],[cName:GeneralPrefs]]],[cName:View, oChildren:[[cName:Rotate, oChildren:[[cName:RotateCW],[cName:RotateCCW]]],[cName:GoTo, oChildren:[[cName:FirstPage],[cName:PrevPage],[cName:NextPage],[cName:LastPage],[cName:GoToPage],[cName:endPageNavGroup],[cName:GoBack],[cName:GoForward]]],[cName:],[cName:PageLayout, oChildren:[[cName:SinglePage],[cName:OneColumn],[cName:TwoPages],[cName:TwoColumns],[cName:endPageLayoutSubGroup],[cName:ShowGaps],[cName:ShowCoverPage],[cName:],[cName:AutoScroll]]],[cName:ZoomSubMenu, oChildren:[[cName:ZoomTo],[cName:Zoom],[cName:ZoomDrag],[cName:],[cName:ActualSize],[cName:FitPage],[cName:FitWidth],[cName:FitHeight],[cName:FitVisible],[cName:endFitGroup],[cName:PanZoom],[cName:Loupe],[cName:],[cName:Reflow]]],[cName:endGoToGroup],[cName:TaskPanesSectionStart],[cName:ShowHideSubMenu, oChildren:[[cName:Navigation, oChildren:[[cName:ShowHideAccessibilityCheck],[cName:ShowHideAccessibilityReport],[cName:ShowHideArticles],[cName:ShowHideFileAttachment],[cName:ShowHideBookmarks],[cName:ShowHideContentPanel],[cName:ShowHideDestinations],[cName:ShowHideOptCont],[cName:ShowHideModelTree],[cName:ShowHideOrderPanel],[cName:ShowHideThumbnails],[cName:ShowHideRecognitionReport],[cName:ShowHideRemoveHiddenInfo],[cName:ShowHideWorkflowPanel],[cName:ShowHideSignatures],[cName:ShowHidePDFStandards],[cName:ShowHideTagsPanel],[cName:endShowHideWindowsGroup2],[cName:ShowHideNavigationPane],[cName:ResetPanels],[cName:]]],[cName:HoldoverToolbars],[cName:ShowHideMenuBar],[cName:],[cName:RulersAndGridsGroup, oChildren:[[cName:ShowGrid],[cName:SnapToGrid],[cName:ShowRulers],[cName:ShowGuides],[cName:Wireframe]]],[cName:ShowInfo]]],[cName:],[cName:ReadingMode],[cName:FullScreenMode],[cName:endFullScreenGroup],[cName:Annots:ReviewTracker],[cName:],[cName:ReadAloud, oChildren:[[cName:ADBE:ReadOutLoudOnOff],[cName:ADBE:ReadAloudStart],[cName:ADBE:ReadAloudToEnd],[cName:ADBE:ReadAloudPauseResume],[cName:ADBE:ReadAloudStop]]],[cName:DIGSIG:CompareDocuments]]],[cName:Window, oChildren:[[cName:NewWindow],[cName:],[cName:Cascade],[cName:Tile, oChildren:[[cName:TileHorizontal],[cName:TileVertical]]],[cName:MinimizeAll],[cName:endWindowLayoutGroup],[cName:SplitWindow],[cName:SpreadsheetSplit]]],[cName:Help, oChildren:[[cName:HelpUserGuide],[cName:endGuideGroup],[cName:About],[cName:AboutAdobeExtensions],[cName:endAboutPlugInGroup],[cName:UsageMeasurement],[cName:],[cName:AMTDynamic1],[cName:AMTDynamic2],[cName:startEBookServicesGroup],[cName:eBook:Digital Edition Services],[cName:endEBookServicesGroup],[cName:OnlineSupport, oChildren:[[cName:KnowledgeBase],[cName:AdobeExpertSupport],[cName:AdobeUserCommunity],[cName:AccessOnline],[cName:],[cName:SystemInformation]]],[cName:DetectAndRepair],[cName:Updates]]]
*/

At a glance I see a ReduceFileSize and PDFOptimizer in there.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

Google Search, Dictionary, Thesaurus - Quickly Get Information from Specific Web Resources

[Function] Timer - Create and Manage Timers
FanaticGuru
Posts: 1164
Joined: 30 Sep 2013, 22:25

Re: Adobe Acrobat Pro via COM

12 Jun 2018, 16:46

MannyKSoSo wrote:I have tried to make a com object but for some reason I keep coming up with that it doesn't know the command.

Just realized this is an old thread.

There are alot of different kinds of COM objects associated with Acrobat. What ComObjCreate command are you trying that fails?

Also, just to be clear to work with Acrobat through COM, you need the paid version of Acrobat. The Reader and free versions don't support COM.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

Google Search, Dictionary, Thesaurus - Quickly Get Information from Specific Web Resources

[Function] Timer - Create and Manage Timers
MannyKSoSo
Posts: 197
Joined: 28 Apr 2018, 21:59

Re: Adobe Acrobat Pro via COM

12 Jun 2018, 16:56

Specifically it has to do with the saveAs part of the code

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

oAcrobat.saveAs(A_ScriptDir "FileToRead.xml", "com.adobe.acrobat.xml-1-00")


The documentation is a little confusing to me on the subject (just because I am still learning all the commands). Also I do indeed have the paid version of Acrobat.

To give a better example of what is happening is that after I read and open the file through the com I try and convert it to an xml file (which works fine if you use the part of the code that is commented out) but I was trying to make it use the built in saveAs. When that specific part of the code runs, it doesn't recognize the action. Thanks!

Return to “Ask For Help”

Who is online

Users browsing this forum: cjj, KiritoSanPlays and 65 guests