Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adobe InDesign .jsx script execute .jsx script

How can I have my .jsx script when finished execute another .jsx script?

Maybe this will help understand what I am trying to do:

// WebCard.jsx file

function mySnippet(){
    //<fragment>
    var myPageName, myFilePath, myFile;
    var myDocument = app.documents.item(0);
    var myBaseName = myDocument.name;
    for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){
        myPageName = myDocument.pages.item(myCounter).name;
        app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
        app.jpegExportPreferences.resolution = 96;
       app.jpegExportPreferences.pageString = myPageName;  

          switch(myPageName) {
        case "1" : myPageName = "EN FRONT WebCard";
            docType = "Web/Web Cards" break;
        case "2" : myPageName = "EN BACK WebCard";
            docType = "Web/Web Cards" break;
        case "3" : myPageName = "ES FRONT WebCard";
            docType = "Web/Web Cards" break;
        case "4" : myPageName = "ES BACK WebCard";
            docType = "Web/Web Cards" break;

    }
        fileName = group + " " + myPageName + " " + date + ".jpg";

        myFilePath = dirPath + docType + "/" + fileName;
        myDocument.exportFile(ExportFormat.jpg, File(myFilePath), false);
    }
    //</fragment>
}
//</snippet>
                // execute PrintCard.jsx file


//<teardown>
function myTeardown(){
}
//</teardown>
like image 543
jmituzas Avatar asked Jan 14 '11 20:01

jmituzas


People also ask

How do I run a script in InDesign?

To run the script, open a document in InDesign, then open the Scripts panel (see above) and double-click the script name. Some scripts require you make a selection first before you run them, because they act on the selection. See if the script writer provided any sort of documentation if you can't figure it out.

Where is script option in InDesign?

Open the Scripts panel Choose Window > Utilities > Scripts.

How do I open a JSX file?

Since JSX files are used in Adobe's programs, you can open them with Photoshop, InDesign, and After Effects from the File > Scripts > Browse menu item. This is also where these programs import JS and JSXBIN files. Like most source code, JSX files are really just text files, so any text editor can open them for editing.


1 Answers

You can easily include another script which will be executed at the point where you include it:

// ... Do something (will be executed before teardown script)


#include "../path/to/teardown/script.jsx" 
// the path can be absolute or relative.

This should work in InDesign from CS3 upwards.

like image 147
Jonas Avatar answered Sep 19 '22 06:09

Jonas