Adobe 0046100128056 Scripting Guide - Page 20
Basic Document Operations, Creating a new document, Opening a document
UPC - 718659087562
View all Adobe 0046100128056 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 20 highlights
CHAPTER 3: Documents Basic Document Operations 20 Basic Document Operations Opening, closing, and saving documents are some of the most basic document tasks. This section shows how to do them using scripting. Creating a new document The following script shows how to make a new document using scripting. (For the complete script, see MakeDocument.) var myDocument = app.documents.add(); To create a document using a document preset, the add method includes an optional parameter you can use to specify a document preset, as shown in the following script. (For the complete script, see MakeDocumentWithPreset.) //Creates a new document using the specified document preset. //Replace "myDocumentPreset" in the following line with the name //of the document preset you want to use. var myDocument = app.documents.add(true, app.documentPresets.item("myDocumentPreset")); You can create a document without displaying it in a window, as shown in the following script fragment (from the MakeDocumentWithParameters tutorial script): //Creates a new document without showing the document window. //The first parameter (showingWindow) controls the visibility of the //document. Hidden documents are not minimized, and will not appear until //you add a new window to the document. var myDocument = app.documents.add(false); //To show the window: var myWindow = myDocument.windows.add(); Some script operations are much faster when the document window is hidden. Opening a document The following script shows how to open an existing document. (For the complete script, see OpenDocument.) app.open(File("/c/myTestDocument.indd")); You can choose to prevent the document from displaying (that is, hide it) by setting the showing window parameter of the open method to false (the default is true). You might want to do this to improve performance of a script. To show a hidden document, create a new window, as shown in the following script fragment (from the OpenDocumentInBackground tutorial script): //Opens an existing document in the background, then shows the document. //You'll have to fill in your own file path. var myDocument = app.open(File("/c/myTestDocument.indd"), false); //At this point, you could do things with the document without showing the //document window. In some cases, scripts will run faster when the document //window is not visible. //When you want to show the hidden document, create a new window. var myLayoutWindow = myDocument.windows.add();