🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #499

Re: JS: CS4 print active document

#499
From: John_Kallios
Date: Mon, 23 Mar 2009 18:08
49 lines
2111 bytes
Hey Dave, (and lurkers)

I got to admit to missing the obvious. The scripting guide also mentioned to check out the sample script "PrintDocumentWithPreset.jsx"

However, when run, it creates a new window, adds a small frame and stops. I named my preset to "ps". (it is printing to postscript)

Is this the line, var myDocument = app.documents.add();, that is creating the new document. Should it not be app.activeDocument? I will be trying to get my mind around this.

(note: just because you responded once does not mean I expect you to keep responding. I value everyone's time :))

//PrintDocumentWithPreset.jsx
//An InDesign CS4 JavaScript
//
//Prints the active document using the specified printer preset.
//Assumes you have a printer preset named "myPrintPreset" and that a document is open.

main();

function main(){
    mySetup();
    mySnippet();
    myTeardown();
}

//<setup>
function mySetup(){
	var myDocument = app.documents.add();
	myDocument.pages.item(0).rectangles.add();
	try{
		app.printerPresets.add({name:"ps"});
	}
	catch(myError){}
}
//</setup>

//<snippet>
function mySnippet(){
    //<fragment>
    //Prints the active document using the specified printer preset.
    var myDocument = app.documents.item(0);
    myDocument.print(false, app.printerPresets.item("ps"));
    //</fragment>
}
//</snippet>

//<teardown>
function myTeardown(){
}
//</teardown>
Technical Details
Message-ID: <59b860c2.3@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news1.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.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: John_Kallios@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news1.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: JS: CS4 print active document
Message-ID: <59b860c2.3@webcrossing.la2eafNXanI>
Date: Mon, 23 Mar 2009 11:08:35 -0700
References: <59b860c2.-1@webcrossing.la2eafNXanI>
Lines: 55
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit