Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


How to call the JSX code within ShellScript?

Community Beginner ,
Oct 25, 2021 Oct 25, 2021

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. 

TOPICS
How to, Scripting

Views

154

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 25, 2021 Oct 25, 2021

Copy link to clipboard

Copied

Note: I want to execute the JSX code within shell script for both Mac and Windows OS.

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 25, 2021 Oct 25, 2021

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.

https://community.adobe.com/t5/after-effects-discussions/run-jsx-file-from-command-line-windows/td-p...

 

Regards,

Mike

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 26, 2021 Oct 26, 2021

Copy link to clipboard

Copied

Thank you Mike. Is that mandatory to use the applescript code for mac?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 27, 2021 Oct 27, 2021

Copy link to clipboard

Copied

Hello @annad38716857,

 

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 27, 2021 Oct 27, 2021

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).

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Oct 27, 2021 Oct 27, 2021

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 28, 2021 Oct 28, 2021

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?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Oct 29, 2021 Oct 29, 2021

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 02, 2021 Nov 02, 2021

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.

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 02, 2021 Nov 02, 2021

Copy link to clipboard

Copied

LATEST

When we sit on discussion definetly we will find some solution fro sure.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines