How to add javascripts to my InDesign Server Java web app?

386 views Asked by At

I wrote a simple Java (1.5)-based web app (deployed on a Tomcat-6-server), which communicates with an InDesign server using CORBA.

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. Unluckily I was unable to identify how to "hook" the scripts into my CORBA application, just like I did with job options.

Unfortunately, the official docs do not tell me how to do this. Can anyone offer help?

1

There are 1 answers

0
Robert Heine On BEST ANSWER

After digging through tons of documentation,(non-existent ;) ) javadocs and the official and unofficial adobe forums, I found a solution by myself.

The CORBA-application owns an undocumented method doScript(arg0, arg1, arg2, arg3, arg4), which does indeed execute scripts. A code snippet like this executes javascript (and maybe other scripts just fine):

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