简体   繁体   English

如何将javascript添加到我的InDesign Server Java Web应用程序?

[英]How to add javascripts to my InDesign Server Java web app?

I wrote a simple Java (1.5)-based web app (deployed on a Tomcat-6-server), which communicates with an InDesign server using CORBA. 我编写了一个简单的基于Java(1.5)的Web应用程序(部署在Tomcat-6服务器上),该应用程序使用CORBA与InDesign服务器进行通信。

After I managed to add job options (stored in separate files within the filesystem), I'd like to do the same for Javascript files, which already work fine in the InDesign client. 在设法添加作业选项(存储在文件系统内的单独文件中)之后,我想对Javascript文件执行相同的操作,这些Javascript文件已在InDesign客户端中正常运行。 Unluckily I was unable to identify how to "hook" the scripts into my CORBA application, just like I did with job options. 不幸的是,就像我对作业选项所做的那样,我无法确定如何将脚本“挂钩”到我的CORBA应用程序中。

Unfortunately, the official docs do not tell me how to do this. 不幸的是,官方文档没有告诉我该怎么做。 Can anyone offer help? 谁能提供帮助?

After digging through tons of documentation,(non-existent ;) ) javadocs and the official and unofficial adobe forums, I found a solution by myself. 在浏览了无数的文档(不存在;))javadocs以及官方和非官方的Adobe论坛之后,我自己找到了解决方案。

The CORBA-application owns an undocumented method doScript(arg0, arg1, arg2, arg3, arg4) , which does indeed execute scripts. CORBA应用程序拥有一个未记录的方法doScript(arg0, arg1, arg2, arg3, arg4) ,该方法的确执行脚本。 A code snippet like this executes javascript (and maybe other scripts just fine): 像这样的代码片段可以执行javascript(也许其他脚本也可以):

String scriptPath = "/path/to/my/javascripts/"; // indesign server needs file access to this folder
VariableType file = VariableTypeUtils.createFile(scriptPath);

// ScriptLanguage.UNKNOWN - 1433299822
// ScriptLanguage.APPLESCRIPT_LANGUAGE - 1095978087
// ScriptLanguage.JAVASCRIPT - 1246973031

// do javascript
OptScriptLanguageEnum scriptType = OptArg.makeScriptLanguageEnum(1246973031);

// add values ...
VariableType[] params = new VariableType[1];
params[0] = VariableTypeUtils.createBoolean(true);
OptVariableTypeSeq args = OptArg.makeVariableTypeSeq(params);

// or if you got no args
args = OptArg.noVariableTypeSeq();

// undo modes
OptUndoModesEnum undoModes = OptArg.noUndoModesEnum();
// string to undo mode
OptString undoName = OptArg.noString();

// add to application
VariableType vt = gApp.doScript(file, scriptType, args, undoModes, undoName);

Hope that anyone can confirm this. 希望任何人都可以确认这一点。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM