G'day ladies and gents.
Problem as follows:
My workflow involves both photoshop and indesign. I run my PS script from an action so I can batch it in bridge. What the script does is open a jpg file, determine it's path size, etc, close it, then open a pdf in PS, rasterize it make some changes to it, save it in output folder, close it, then what I want to do is to run js for indesign that imports a multipage pdf, save and close. Where I'm at:
Code: Select all[...]
//all photoshop script rubbish that works fine
var destindd = new File(folder+'/'+orderInvoice+"_"+orderTemplate+'.indd');
destindd.execute(); //that opens indd file just fine
//#target indesign-6.0.6
//var script=new File("~/Desktop/PlaceAPDF_master_NEW.jsx");
script.execute();//that runs a script ok, but throws a message as if the script was ran from desktop, not from indesign
that all works fine indesign file opens, but it comes up with a message that I'm opening a script and it's not safe, blah blah blah and am I sure that I want to do it... and I need to press OK to keep processing files.
"include" will not work in this case and I can't seem to change a #target app half way through the script.
I thought of executing a script in indesign on file open but can't think of any clean way to do it. I don't want to trigger the script every time I open an indd file.
help appreciated.
Matt
Switching between applications
Switching between applications
From what I have seen of ESTK you can't change your '#target' mid script once the engine is running is off till its finished… Or at least thats I think it works. (X will say for sure). What you should be looking at is cross application communication in the scripting guides. This is 'bridgetalk' and its script messaging system. You could try placing your ID script file in a trusted location but I don't think this is going to do what you wish. From a personal point of view I would have worked this the other way around and started with the ID doc using the built-in function getFilesFrom Bridge() or something close to that… Placed them then called out to PS to make the edits close n save then update modified links…
Switching between applications
I'll add my vote to Bridgetalk. I have a couple of Photoshop scripts that send Bridgetalk messages to InDesign to make multi page PDFs now that it can't be done in Photoshop. Especially if you need to pass arguments.
If you don't need to pass arguments you could try something like this in your Photoshop script
Code: Select allindesign.executeScriptFile(new File("~/Desktop/PlaceAPDF_master_NEW.jsx"));
At least on my WInXP system that will call the indesign script from a Photoshop CS4 script without using Bridgetalk or the script warning message. I think that execute() goes through the OS and executeScriptFile() runs under Indesign as part of it's startup script.
If you don't need to pass arguments you could try something like this in your Photoshop script
Code: Select allindesign.executeScriptFile(new File("~/Desktop/PlaceAPDF_master_NEW.jsx"));
At least on my WInXP system that will call the indesign script from a Photoshop CS4 script without using Bridgetalk or the script warning message. I think that execute() goes through the OS and executeScriptFile() runs under Indesign as part of it's startup script.
Switching between applications
Mike Hale wrote:If you don't need to pass arguments you could try something like this in your Photoshop script
Code: Select allindesign.executeScriptFile(new File("~/Desktop/PlaceAPDF_master_NEW.jsx"));
That didn't work for me. Shame because it looks like just what I need. Is "indesign" a variable that I have to define in this instance?
The reason why I start in PS is because I have to pull a specific ID template for pdf import file from repository based on the size of the jpg file that's in the order's folder and some xml tags from a file in the same folder so it was easy for me to select a few or few hundred jpgs in bridge and run a script on them effectively processing these orders linked to the jpg files, and as much as I know a bit about js for PS or ID, bridgetalk is something entirely new to me.
Code: Select allindesign.executeScriptFile(new File("~/Desktop/PlaceAPDF_master_NEW.jsx"));
That didn't work for me. Shame because it looks like just what I need. Is "indesign" a variable that I have to define in this instance?
The reason why I start in PS is because I have to pull a specific ID template for pdf import file from repository based on the size of the jpg file that's in the order's folder and some xml tags from a file in the same folder so it was easy for me to select a few or few hundred jpgs in bridge and run a script on them effectively processing these orders linked to the jpg files, and as much as I know a bit about js for PS or ID, bridgetalk is something entirely new to me.
Switching between applications
What version of CS do you have?
indesign is defined in the InDesign startup script and is used for cross-DOM support.
I don't have the CS5 suite(just Photoshop) so I can't test with that version but both CS4 and CS3 has the needed startup script.
indesign is defined in the InDesign startup script and is used for cross-DOM support.
I don't have the CS5 suite(just Photoshop) so I can't test with that version but both CS4 and CS3 has the needed startup script.
Switching between applications
Mike Hale wrote:What version of CS do you have?
I work in PS CS5 and ID CS4 (simply because the ID plugins for the printing press are not available for CS5 yet) but I wouldn't have a problem working entirely in CS4 if that solves my problem... Will it?
I work in PS CS5 and ID CS4 (simply because the ID plugins for the printing press are not available for CS5 yet) but I wouldn't have a problem working entirely in CS4 if that solves my problem... Will it?
Switching between applications
I tried in CS4 and I'm getting this:
Error 2: indesign is undefined.
Line: 517
-> indesign.executeScriptFile(new File("~/Desktop/PlaceAPDF_master_NEW.jsx"));
Error 2: indesign is undefined.
Line: 517
-> indesign.executeScriptFile(new File("~/Desktop/PlaceAPDF_master_NEW.jsx"));
Switching between applications
I'm not sure why that is not working for you. At least on my system I have indesign6.jsx in C:\Program Files\Common Files\Adobe\Startup Scripts CS4\Adobe InDesign. That startup script defines the cross-DOM methods for InDesign CS4. Those methods can be called from Bridge, Photoshop, Illustrator, Dreamweaver, etc.
Switching between applications
yep, I got all that in startup scripts directories... So I don't know where the problem is. Can anyone point me to some documentation on proper settings of these?
Switching between applications
OK. I looked here and there, got some bridgetalk sample scripts and I'm here:
if I run this from PS it will tell me the size of the jpg, then I want it to open ID create a frame, which it does, and put this size (thumbWidth) in the frame instead of the text. Can anyone help me with this, pretty please?
Code: Select allvar doc = app.activeDocument;
var thumbWidth = doc.width;
alert(thumbWidth);
function SnpSendMessageToInDesign() {
this.requiredContext = "\tExecute against Bridge CS5 main engine,\n InDesign CS5 must also be running.";
$.level = 1; // Debugging level
}
SnpSendMessageToInDesign.prototype.run = function() {
var retval = true;
if(!this.canRun()) {
retval = false;
return retval;
}
// Create the message object
var bt = new BridgeTalk();
// Initialize with the target and message string
bt.target = "indesign-6.0.6";
bt.body = "var SnpSentMessage = {}; SnpSentMessage.create = " + createInDesignObjects.toString();
bt.body += "SnpSentMessage.create();"
bt.onError = function(errObj)
{
$.writeln(errObj.body);
}
bt.onResult = function(resObj)
{
var retval = eval(resObj.body);
$.writeln("SnpSendMessageToInDesign: (Bridge) received result = " + retval);
$.writeln("SnpSendMessageToInDesign: (Bridge) the process of creating objects in InDesign has finished...");
BridgeTalk.bringToFront("indesign-6.0.6");
}
bt.send();
$.writeln("SnpSendMessageToInDesign: (Bridge) BridgeTalk.send() invoked, SnpSendMessageToInDesign.run() exiting");
return retval;
}
SnpSendMessageToInDesign.prototype.canRun = function() {
// Must run in PS
// InDesign must be running
if((BridgeTalk.appName == "photoshop") && BridgeTalk.isRunning("indesign-6.0.6")) {
return true;
}
// Fail if these preconditions are not met.
$.writeln("ERROR:: Cannot run SnpSendMessageToInDesign");
$.writeln(this.requiredContext);
return false;
}
function createInDesignObjects() {
$.writeln("SnpSendMessageToInDesign: (InDesign) entering createInDesignObjects");
// var mydoc = app.activeDocument;
var mydoc = app.documents.add();
with(mydoc.pages.item(0)) {
myframe = textFrames.add(mydoc.layers.item("Layer 1"));
myframe.geometricBounds = ["20mm", "50mm", "40mm", "140mm"];
myframe.contents = "This is where the variable should go";
}
$.writeln("SnpSendMessageToInDesign: (InDesign) leaving createInDesignObjects");
return true;
}
if(typeof(SnpSendMessageToInDesign_unitTest ) == "undefined") {
new SnpSendMessageToInDesign().run();
}
if I run this from PS it will tell me the size of the jpg, then I want it to open ID create a frame, which it does, and put this size (thumbWidth) in the frame instead of the text. Can anyone help me with this, pretty please?
Code: Select allvar doc = app.activeDocument;
var thumbWidth = doc.width;
alert(thumbWidth);
function SnpSendMessageToInDesign() {
this.requiredContext = "\tExecute against Bridge CS5 main engine,\n InDesign CS5 must also be running.";
$.level = 1; // Debugging level
}
SnpSendMessageToInDesign.prototype.run = function() {
var retval = true;
if(!this.canRun()) {
retval = false;
return retval;
}
// Create the message object
var bt = new BridgeTalk();
// Initialize with the target and message string
bt.target = "indesign-6.0.6";
bt.body = "var SnpSentMessage = {}; SnpSentMessage.create = " + createInDesignObjects.toString();
bt.body += "SnpSentMessage.create();"
bt.onError = function(errObj)
{
$.writeln(errObj.body);
}
bt.onResult = function(resObj)
{
var retval = eval(resObj.body);
$.writeln("SnpSendMessageToInDesign: (Bridge) received result = " + retval);
$.writeln("SnpSendMessageToInDesign: (Bridge) the process of creating objects in InDesign has finished...");
BridgeTalk.bringToFront("indesign-6.0.6");
}
bt.send();
$.writeln("SnpSendMessageToInDesign: (Bridge) BridgeTalk.send() invoked, SnpSendMessageToInDesign.run() exiting");
return retval;
}
SnpSendMessageToInDesign.prototype.canRun = function() {
// Must run in PS
// InDesign must be running
if((BridgeTalk.appName == "photoshop") && BridgeTalk.isRunning("indesign-6.0.6")) {
return true;
}
// Fail if these preconditions are not met.
$.writeln("ERROR:: Cannot run SnpSendMessageToInDesign");
$.writeln(this.requiredContext);
return false;
}
function createInDesignObjects() {
$.writeln("SnpSendMessageToInDesign: (InDesign) entering createInDesignObjects");
// var mydoc = app.activeDocument;
var mydoc = app.documents.add();
with(mydoc.pages.item(0)) {
myframe = textFrames.add(mydoc.layers.item("Layer 1"));
myframe.geometricBounds = ["20mm", "50mm", "40mm", "140mm"];
myframe.contents = "This is where the variable should go";
}
$.writeln("SnpSendMessageToInDesign: (InDesign) leaving createInDesignObjects");
return true;
}
if(typeof(SnpSendMessageToInDesign_unitTest ) == "undefined") {
new SnpSendMessageToInDesign().run();
}