How to call the JSX code within ShellScript?
Copy link to clipboard
Copied
Hi All,
I have a code for PDF export. I wanted to call this code/file within shellscript.
#targetengine "session"
exportPDF();
function exportPDF() {
var fileid = Date.now();
var targetFile = new File(Folder.temp.absoluteURI + "/" + fileid);
//preset
var PDFpreset = getPDFPreset();
var docs = app.documents[0];
docs.exportFile(ExportFormat.pdfType, targetFile, false, PDFpreset);
}
function getPDFPreset() {
var myPrefs = myPrefs = app.pdfExportPresets.add();
myPrefs.name = "expPDF";
return myPrefs;
}
Could anyone help me on this request.
Thanks.
Copy link to clipboard
Copied
Note: I want to execute the JSX code within shell script for both Mac and Windows OS.
Copy link to clipboard
Copied
Hello @anna duraim38716857,
This works on Mac OS, you will just need to change the file path and name of the .jsx file.
osascript -e 'tell application id "com.adobe.indesign" to do script (posix file "/Users/User-Name/Desktop/Your-Script.jsx") language javascript'
For Windows see the post below.
Regards,
Mike
Copy link to clipboard
Copied
Thank you Mike. Is that mandatory to use the applescript code for mac?
Copy link to clipboard
Copied
Hello @ad_ind38716857,
Re: This works on Mac OS, you will just need to change the file path and name of the .jsx file.
osascript -e 'tell application id "com.adobe.indesign" to do script (posix file "/Users/User-Name/Desktop/Your-Script.jsx") language javascript'
You don't run the above code as an Applescript, copy and paste into the Terminal app to execute.
osascript is a command to run the script from the shell.
Regards,
Mike
Copy link to clipboard
Copied
Sadly though, this does use AppleScript to run the JavaScript. This means it's subject to Apple's byzantine security preferences. (I wouldn't mind them, except that I find they keep turning off when I'm in the middle of a live session).
Copy link to clipboard
Copied
As far as windows is concerned, you can do like this with VBscript :
Set myInDesign = CreateObject("InDesignServer.Application")
Set myInDesign = GetObject("configuration_12345")
myJavaScript = "app.doScript(File('C:/Users/sunil/Desktop/test.jsx'));"
myInDesign.DoScript myJavaScript, 1246973031
I am not good with appleScript, so can not say much about that.
Note : "configuartion_12345" here "12345" is port number of session created for InDesign Server.
Best
Sunil
Copy link to clipboard
Copied
Thank you Sunil for your reply. But I want to call the JSX script file with in the Shell script. Is that possible?
Copy link to clipboard
Copied
See VB script,
I have executed JSX script from VBscript targeting a session of InDesign Server,
Same way you also might do it using Shell Script.
Sunil
Copy link to clipboard
Copied
Hi Sunil,
Sorry for the late reply. Honestly, I don't know how to use it from shell script. Do you have any idea on that?
Thanks.
Copy link to clipboard
Copied
When we sit on discussion definetly we will find some solution fro sure.

