4 Replies Latest reply on Feb 1, 2017 10:56 AM by epsobolik

    Print with Print Presets

    Babymac08 Level 1

      I'm totally missing what should be an obvious script... but I've tried several options that I've found in various forums... and I've yet to suceed...

       

      I simply need a script that I can print the current document based on a Print Preset "PrintMe" and I'd prefer it to have no user interactions... just simply print..

       

      Any help?

        • 1. Re: Print with Print Presets
          o-marat Level 3

          Hi,  Babymac08!

          Try this code:

          var storeUserInteract = userInteractionLevel;
          var d                 = activeDocument;
          var filePath          = '/d/test_prnt.ps' // your print file name
          var jbOpts            = new PrintJobOptions();
          var opts              = new PrintOptions();
          opts.printPreset      = "PrintMe";
          opts.jobOptions       = jbOpts;
          jbOpts.file           = new File(filePath);
          userInteractionLevel  = UserInteractionLevel.DONTDISPLAYALERTS;
          d.print(opts);
          userInteractionLevel = storeUserInteract;
          
          • 2. Re: Print with Print Presets
            Babymac08 Level 1

            Thank you so much... Works perfect

             

            I did modify slightly to remove the file path option and it worked flawlessly...

             

            var storeUserInteract = userInteractionLevel; 

            var d                 = activeDocument; 

            var jbOpts            = new PrintJobOptions(); 

            var opts              = new PrintOptions(); 

            opts.printPreset      = "PrintMe";  //Insert Your Own Custom Print preset between quotes

            opts.jobOptions       = jbOpts; 

            userInteractionLevel  = UserInteractionLevel.DONTDISPLAYALERTS; 

            d.print(opts); 

            userInteractionLevel = storeUserInteract; 

            • 3. Re: Print with Print Presets
              epsobolik

              I'm sure this works if you are working on a script from within Illustrator.  I am working on a script that updates the version and copyright year of 30 CD labels.  This was working with a previous version of Illustrator.  We have since upgraded to CS3 ().  However, it is an external JavaScript script (.js).  It successfully opens the file, updates the the appropriate text fields, and saves the modified file.  However, when I print (using a printer driver that prints to a file), it asks for a file to print to.  Since each .prn file will have the same base name as the Illustrator file, I can't include the file name in the printer driver settings.  I see in the Illustrator.jobOptions the is a 'file' member of type File.  This appears to be an internal File object rather than a FileSystemObject File.  Is there a way I can specify the filename of the output file when printing?

               

              BTW, the documentation for using external JavaScript scripts says that it is 'beyond the scope of the documentation'.  It's actually no more difficult than writing external VBScript scripts.  You just use new ActiveXObject() instead of CreateObject().

              • 4. Re: Print with Print Presets
                epsobolik Level 1

                Figured it out.  I followed the suggestion for VBScript and ran MS Word's VBA editor and looked at the Illustrator object model with the object browser.  The spec' for the File member of PrintJobOptions is just String.  So, I created a PrintJobOptions object, set the File member to the name of the file I wanted to print to, and set the PrintOptions.jobOptions member to the PrintJobOptions that I had just created.  It works great.  Thanks anyway.