首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >InDesign .jsx脚本执行.jsx脚本

InDesign .jsx脚本执行.jsx脚本
EN

Stack Overflow用户
提问于 2011-01-15 04:11:35
回答 2查看 5.9K关注 0票数 5

执行完另一个.jsx脚本后,如何让我的.jsx脚本执行?

也许这将有助于理解我正在尝试做的事情:

代码语言:javascript
复制
// 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>
EN

回答 2

Stack Overflow用户

发布于 2011-02-10 21:37:32

您可以轻松地包含另一个脚本,该脚本将在包含该脚本的位置执行:

代码语言:javascript
复制
// ... Do something (will be executed before teardown script)


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

这应该可以在CS3以上的InDesign中工作。

票数 5
EN

Stack Overflow用户

发布于 2011-01-15 04:26:54

下面是我用来启动其他脚本的一些ExtendScript片段;我在After Effects中使用过它,但它在InDesign中可能也有效:

代码语言:javascript
复制
var theScriptFile = new File("/path/to/file.jsx");

var oldCurrentFolder = Folder.current;
Folder.current = theScriptFile.parent;

theScriptFile.open();
var theScriptContents = theScriptFile.read();
theScriptFile.close();

gCurrentScriptFile = theScriptFile;

if(doDebug)
    debugger;

// You have entered the debugger in Launcher...
// to debug the script you've launched, step
// into the eval() function below. 
//
eval( "{" + theScriptContents + "}" );

Folder.current = oldCurrentFolder;
gCurrentScriptFile = "";

方法是读取文件并对其求值。(附注:另一个很好的标签是ExtendScript。)另请参阅:http://omino.com/pixelblog/2007/11/15/binary-files-in-extendscript/

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4695444

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档