Skip to main content
Participant
January 20, 2016
Answered

How to apply the js API in external js?

  • January 20, 2016
  • 7 replies
  • 1477 views

In Acrobat DC's javascript debugger, I can convert pdf file to xml using codes like below.

var myDoc = app.openDoc("/C/Users/EAGLE/Desktop/test.pdf");

myDoc.saveAs("/C/Users/EAGLE/Desktop/test.xml", "com.adobe.acrobat.xml-1-00")

I want to implement this function in external js script for batch of my PDF files. Please tell me how to do this. THX~~~

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer try67

You mean call it in Acrobat DC? Can I do the conversion without opening Acrobat DC, without its console and action?


No, Acrobat is not suited for that kind of automation.

If you want you can place the code outside a function, though. That way it will immediately execute each time you open the application...

7 replies

try67
Community Expert
Community Expert
January 20, 2016

Do you mean as a part of an Action in Acrobat Pro?

Participant
January 20, 2016

If I create a js file on my computer/desktop, how can I invoke the acrobat api in it? like the app.openDoc() and saveAs()?

try67
Community Expert
Community Expert
January 20, 2016

You need to place the code inside a function and then call it. Like this:

In the folder-level script:

function myExportAsXML() {

    // Put your code here...

}

In your Action, or from a menu item, or the console, etc.:

myExportAsXML();