🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #475

Re: JS: CS4 print active document

#475
From: Dave_Saunders
Date: Mon, 23 Mar 2009 00:22
33 lines
2452 bytes
John,

First problem is that you are saving your script as rtf so it has no hope of working.

Look in the Adobe Utilities folder and fire up ExtendScript Toolkit CS4. Use File/New to make a new script document. Copy and paste your script from TextEdit (I assume that's what you're using) to your script document.

Now go to the Help menu and fire up the Object Model Viewer. Under Browser, choose the InDesign CS4 object model. Under Classes, choose Document. Under properties and methods, choose the method print(). That shows you the full syntax of the print method.

It shows you this:

Document.print (printDialog: Boolean , using:any)
Adobe InDesign CS4 (6.0) Object Model Object Model
Prints the Document(s).
printDialog: Data Type: Boolean
Whether to invoke the print dialog (Optional)
using: Data Type: any
Printer preset to use. Can accept: PrinterPresetTypes enumerator or PrinterPreset. (Optional)

This might be a bit hard to understand for the uninitiated. The call takes two arguments. The first is a boolean (true or false) indicating whether to show the dialog. The second indicates which PrinterPreset to use.

Since you want to use a specific one for which you know the name, you must first get a reference to it. PrinterPresets also are objects. Look under Classes again for PrinterPreset (singular). And now look under Properties and Methods again, this time look for the parent property. Notice that the parent is the application object.

This means that to get a reference to the preset you want you need to write:

myPreset = app.printerPresets.item("Myoutput");

and now you can write:

app.activeDocument.print(false, myPreset);

Hope this helps not just with the immediate problem but also with how to go about solving these kinds of issues.

Dave
Technical Details
Message-ID: <59b860c2.0@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news.astraweb.com!border5.newsrouter.astraweb.com!newshub.sdsu.edu!webcrossing
References: <59b860c2.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,b00375fe3369de3e
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: Dave_Saunders@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news.astraweb.com!border5.newsrouter.astraweb.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: JS: CS4 print active document
Message-ID: <59b860c2.0@webcrossing.la2eafNXanI>
Date: Sun, 22 Mar 2009 17:22:33 -0700
References: <59b860c2.-1@webcrossing.la2eafNXanI>
Lines: 50
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit