6 Replies Latest reply on Jul 23, 2008 2:48 PM by (Richard_Holstein)

    Create package in indesign CS using javascript

      Hi.
      Can I make a javascript script to make a package automatic.
      I made this script but it's don't work.

      with (myDocument.package){
      to = pathToMyFile;
      }
        • 1. Re: Create package in indesign CS using javascript
          [Jongware] Most Valuable Participant
          No wonder, you made more than a few errors in the first line alone. ;-)

          First of all, it's not "package" (that appears to be a reserved JS word -- you learn something useful every day), it's "packageForPrint". Next, that is a function; you can't use "with" with functions, only with properties. Next, you forgot a lot of required parameters.

          Putting it all together as it should be gives me this line

          >app.activeDocument.packageForPrint("c:\\",true,true,true,true,true,true);

          which works on my system. The sequence of true's can even be amended with two more parameters, a version comment string and a Force Save flag, but at this point you should check the JS help for its correct syntax and the meaning of all these trues.

          (A later thought: you write
          >I made this script

          while the 3 lines hardly qualify as a complete script. Maybe you should know that "myDocument" and "pathToMyFile" can also throw an error, as these variables are undefined and you have to give them a reasonable value first. That's why I used "app.activeDocument".
          Of course, if this is a mere snippet of a complete script, it's no problem, but you should have mentioned that.)
          • 2. Re: Create package in indesign CS using javascript
            Kasyan Servetsky Level 5
            Hi cubas,

            I don't have CS version any more, but this works in CS3:

            var myDocument = app.activeDocument;
            var myFolder = Folder.selectDialog("Please select path to files");
            myDocument.packageForPrint(myFolder, false, true, false, true, true, false);

            As far as I remember, there is a mistake in CS scripting reference: it says package instead of packageForPrint. So try the following syntax:
            myDocument.packageForPrint(to Folder/alias/path, copyingFonts,copyingLinkedGraphics, copyingProfiles, updatingGraphics, includingHiddenLayers, ignorePreflightErrors,creatingReport);

            Kasyan
            • 3. Re: Create package in indesign CS using javascript
              Level 1
              Hi,
              I tested the script above and don't work in indesign cs1 maybe, this function don't work in this indesign version. Can I use other javascript function in indesign cs1 to make a package?

              Thanks

              Carlos
              • 4. Re: Create package in indesign CS using javascript
                Kasyan Servetsky Level 5
                The parameters for the packageForPrint method are different for CS1 and CS3. CS3 has 7 required and 2 optional parameters and cs1 has 8 required parameters - so you should set them all. I gave you an example for CS3 and a list of parameters for CS1 (taken from ID CS scripting reference) that you should choose yourself:
                1)the folder, into which you want to package the document.
                2) Do you want to copy fonts?
                3) Do you want to copy linked graphics?
                and so on – the same parameters as in the user inteface.

                All parameters except the first are boolean, so you should set them totrue or false.

                For CS1 you should set all 8 parameters, e.g.

                var myDocument = app.activeDocument;
                var myFolder = Folder.selectDialog("Please select a folder");
                myDocument.packageForPrint(myFolder, false, true, false, true, false, true, false);

                But I can't check this code myself - don't have CS1 anymore.

                Kasyan
                • 5. Re: Create package in indesign CS using javascript
                  Level 1
                  Thanks Kasyan .
                  This script worked very well.

                  Carlos Cubas
                  • 6. Re: Create package in indesign CS using javascript
                    Great! now instead of having a dialog to point to a folder to receive the package; how about a dialog that would create a new folder with the file's name in place that I would just need to alter a bit.
                    That would be real nice.

                    Thanks,
                    Richard