3 Replies Latest reply on Jul 26, 2012 5:05 AM by swarup83

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

    RobertHeine

      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?

      Regs

      Rob

        • 1. Re: How to add javascripts to my InDesign Server Java web app?
          swarup83

          If you are trying to run a script from java using CORBA, you can use the doScript(...) method exposed on the Application object of CORBA.

           

          Thanks

          Swarup

          • 2. Re: How to add javascripts to my InDesign Server Java web app?
            RobertHeine Level 1

            Hi swarup83,

             

            many thanks for hinting to the correct method, unluckily I suffer the next problem, there seems to be no javadoc on

            what I have to stick into it. Can you provide a simple example?

             

            Regs

            Rob

            • 3. Re: How to add javascripts to my InDesign Server Java web app?
              swarup83 Level 1

                                            String scriptPath = "your_script_file_path"

                                            VariableType file = VariableTypeUtils.createFile(scriptPath);

                                            // ScriptLanguage.APPLESCRIPT_LANGUAGE - 1095978087

                                            // ScriptLanguage.JAVASCRIPT - 1246973031

                                            // ScriptLanguage.UNKNOWN - 1433299822

                                            OptScriptLanguageEnum scriptType = OptArg.makeScriptLanguageEnum(1246973031);

                                            // add values if you want to send arguments to the script

                                            VariableType[] params = new VariableType[1];

                                            params[0] = VariableTypeUtils.createBoolean(true);

                                            OptVariableTypeSeq args = OptArg.makeVariableTypeSeq(params);

                                            // this is for no arguments

                                            OptVariableTypeSeq args = OptArg.noVariableTypeSeq();

                                            OptUndoModesEnum undoModes = OptArg.noUndoModesEnum();

                                            OptString undoName = OptArg.noString();

                                            VariableType vt = gApp.doScript(file, scriptType, args, undoModes, undoName);

               

              No idea if this will work in the first go.

               

              Thanks

              Swarup

              1 person found this helpful