-
1. Re: How does printerList work?
Muppet Mark-QAl63s Dec 5, 2009 6:40 AM (in response to epsobolik)Phil, I had a problem with 'printerList' myself. So I had a look at your script (bare in mind Im pretty new to JavaScript)
It would appear that although printerList is a property of app it is only available whilst a doc is open (which is where I was falling over)
In your case your script ensures that this is the case by creating a new one first.
Your script worked for me with one or two minor tweeks (a typo that returned undefined throughout)
'printerInf' should have been 'printerInfo'
I also changed the line endings to returns like so:
#target illustrator
var docRef = documents.add();
var textRef = docRef.textFrames.add();
var iCount = printerList.length;
textRef.contents = "Checking Printers... \r";
textRef.contents += "Open documents = " + documents.length + "\r" + "\r"
for (var i = 0; i < iCount; ++i) {
textRef.contents += printerList[i].name + "\r";
textRef.contents += "\tPS Level = " + printerList[i].printerInfo.postScriptLevel + "\r";
textRef.contents += "\tDevice resolution = " + printerList[i].printerInfo.deviceResolution + "\r";
textRef.contents += "\tInRIPSeparation support = " + printerList[i].printerInfo.inRIPSeparationSupport + "\r" + "\r";
}
textRef.top = 600;
textRef.left = 200;
redraw();
So I think cases where a new doc is not being created this should be checked like so:
#target illustrator
with (app) {
if (documents.length > 0) {
var iCount = printerList.length;
$.write(iCount);
}
else {
alert('This ONLY works when a doc is open?');
}
}
As for your 'ActiveXObject' I do NOT Know of this so can't help & 'stand-alone javascript' what do you mean by this? Out side of ESTK?
-
2. Re: How does printerList work?
epsobolik Dec 6, 2009 9:04 AM (in response to Muppet Mark-QAl63s)Thanks for replying. I saw that a document had to be opened in order for printerList to be valid. The code I used is from the documentation that is included with Acrobat.
I'm running under Windows, so /n is better than /r. /r will go to the beginning of the same line.
Windows has a scripting environment - WSH - Windows Scripting Host - that allows JavaScript (JScript, technically) or VB Script (or any other scripting language that some one wants to implement) to run at a DOS prompt. You get access to the file system, etc. via ActiveX objects. So, to use Acrobat scripting without being in Illustrator, you just create an Illustrator.Application ActiveXObject and proceed. I wanted to update the version in a bunch of CD label image files.
I ended up creating a print preset in Illustrator with the printer that I wanted to use and then selected that preset in the script. I went a step further in my printerList search, however. I found the ExtendScript development environment and opened a document. Lo and behold, printerList was invalid. I could browse other stuff, but not printerList. I think there is something messed up with the interface to Windows printers - not an uncommon situation. Anyway, I got what I wanted done.
Phil

