19 Replies Latest reply: Aug 29, 2012 9:49 AM by Muppet Mark RSS

    Ai Packaging Script

    Andymc7 Community Member

      Ok.. I'm sure this has been posted before (already searched, didn't find however), but does a file packaging script exist for AI? (one that collects all linked images and fonts and places them in one place) This would be IMMENSELY helpful to me if anyone can post a link to one or even be willing to write it.

       

      OS: W7

      AI Version: CS5

       

      Thanks in advance!

        • 1. Re: Ai Packaging Script
          CarlosCanto CommunityMVP

          Hi, on the "more like this" panel to your right there another post, see if it helps

           

          http://forums.adobe.com/message/4210592#4210592

          • 2. Re: Ai Packaging Script
            Andymc7 Community Member

            Thanks for the links Carlos, but I'm on a pc, so I need a script/plugin that will run for me.

            • 3. Re: Ai Packaging Script
              CarlosCanto CommunityMVP

              in that thread, it is mentioned there's a script that ships with illustrator that collects the ai file and the placed images, but not the fonts.

              • 4. Re: Ai Packaging Script
                Andymc7 Community Member

                Yeah I've tried running the CollectForOutput script but I get an error message that reads "ActiveX component can't create object: 'Illustrator .Application'". So, not sure what that means.

                • 5. Re: Ai Packaging Script
                  CarlosCanto CommunityMVP

                  one possible reason is you might not be an administrator, even if you are. Close illustrator and right click on it and chose "run as administrator", then try running the script.

                  • 6. Re: Ai Packaging Script
                    Andymc7 Community Member

                    Nope, that didn't fix it. :\

                    • 7. Re: Ai Packaging Script
                      pwever

                      Here is a package script I have been using. It collects linked files, but not fonts. Instead it ask whether or not you want to outline all text elements.

                      Only tested on a Mac though. Good luck. // Pascal

                       

                      // This script exports a package of the currently active document.

                      // Choose output folder, and indicate whether or not you want to

                      // outline text elements.

                       

                       

                      const FILE_SUFFIX = "-export";

                      const ASSET_SUFFIX = "-assets";

                      var doc = app.activeDocument;

                      if (!doc.saved) doc.save();

                      var original_file = doc.fullName;

                       

                       

                       

                       

                      // create text outlines if desired.

                      if (confirm("Create text outlines?", true)) { while (doc.textFrames.length != 0) { doc.textFrames[0].createOutline(); }}

                       

                       

                       

                       

                      // collect all linked files

                      var export_folder = Folder.selectDialog("Choose a folder to package into.");

                      var arr = doc.name.split(".");

                      var extension = "";

                      if (arr.length>1) extension = "." + arr.pop();

                      var filename = arr.join(".");

                      var assets_folder = new Folder(export_folder + "/" + filename + ASSET_SUFFIX);

                      if (assets_folder.exists || assets_folder.create()) {

                                var i, in_file, out_file;

                                for (i=0;i<doc.placedItems.length;i++) {

                                          in_file = doc.placedItems[i].file;

                                          out_file = File(assets_folder+"/"+in_file.name);

                                          in_file.copy(out_file);

                                          doc.placedItems[i].file = out_file;

                                }

                                for (i=0;i<doc.rasterItems.length;i++) {

                                          if (doc.rasterItems[i].embedded) continue;

                                          in_file = doc.rasterItems[i].file;

                                          out_file = File(assets_folder+"/"+in_file.name);

                                          in_file.copy(out_file);

                                          doc.rasterItems[i].file = out_file;

                                }

                       

                                // save as new file

                                packaged_file = File(export_folder + "/" + filename + FILE_SUFFIX + extension);

                                doc.saveAs(packaged_file);

                                doc.close();

                       

                                // re-open the original file

                                app.open(File(original_file));

                       

                      } else {

                                alert("Unable to create the assets folder.");

                      }

                      • 8. Re: Ai Packaging Script
                        Andymc7 Community Member

                        Thanks so much! this will certainly get me on my way. the CollectForOutput script that comes with AI doesn't let you choose the output folder, but makes one for you, so this is better.

                        • 9. Re: Ai Packaging Script
                          Andymc7 Community Member

                          Hi, I had some questions about the above script, which is working great,....

                           

                          - How can I get this to overwrite a previously saved AI file?

                          - How can I save the file with pdf compatibility option unchecked, but embed ICC profiles checked?

                           

                          Thanks!

                          • 10. Re: Ai Packaging Script
                            pwever Community Member

                            Untested, but I think all you need to do is add a IllustratorSaveOption object:

                             

                                 // save as new file
                                 packaged_file = File(export_folder + "/" + filename + FILE_SUFFIX + extension);
                                 var save_options = new IllustratorSaveOptions();
                                 save_options.embedICCProfile = true;
                                 save_options.pdfCompatible = false
                                 doc.saveAs(packaged_file, save_options);
                                 doc.close();
                            

                             

                            Good luck. // p

                            • 11. Re: Ai Packaging Script
                              Larry G. Schneider CommunityMVP

                              The real packaging script for AI is a Press-Ready or High Quality output PDF. It does everything that a script would do and everything is in one file.

                              • 12. Re: Ai Packaging Script
                                Andymc7 Community Member

                                Sweet pwever, thanks so much!

                                 

                                Larry, you're correct, but I'd like to utilize this packaging script because I work with other designers and share links/graphics at times.

                                • 13. Re: Ai Packaging Script
                                  rik121

                                  I apologize for my "noobiness"...

                                  How do we use this.

                                  I know how to use scripts but I am not sure how to use your text to apply your script.  Can you PM me the script file?

                                  I tried using the script console tool but didnt have much luck.

                                  Thanks!

                                  • 14. Re: Ai Packaging Script
                                    fuzzyteddy

                                    hey pwever,

                                     

                                    Wow you're a lifesaver.. had the same problem as andymc7. Btw, do you know how I can into the script for it to not only save an ai. copy but also a pdf. and eps. copy while collecting? Thanks in advance.

                                    • 15. Re: Ai Packaging Script
                                      pwever Community Member

                                      Fuzzyteddy,

                                      here is a version that should export an AI, PDF and EPS file.

                                      Hope it helps // p

                                       

                                      Download at https://www.dropbox.com/s/lomfrkj7rt94sqk/Package-extra.js

                                       

                                      or copy below.

                                       

                                      // This script exports a package of the currently active document.
                                      // Choose output folder, and indicate whether or not you want to 
                                      // outline text elements.
                                      
                                      const FILE_SUFFIX = "-export";
                                      const ASSET_SUFFIX = "-assets";
                                      var doc = app.activeDocument;
                                      if (!doc.saved) doc.save();
                                      var original_file = doc.fullName;
                                      
                                      
                                      // create text outlines if desired.
                                      if (confirm("Create text outlines?", true)) { while (doc.textFrames.length != 0) { doc.textFrames[0].createOutline(); }}
                                      
                                      
                                      // collect all linked files
                                      var export_folder = Folder.selectDialog("Choose a folder to package into.");
                                      var arr = doc.name.split(".");
                                      var extension = "";
                                      if (arr.length>1) extension = "." + arr.pop();
                                      var filename = arr.join(".");
                                      var assets_folder = new Folder(export_folder + "/" + filename + ASSET_SUFFIX);
                                      if (assets_folder.exists || assets_folder.create()) {
                                           var i, in_file, out_file;
                                           for (i=0;i<doc.placedItems.length;i++) {
                                                in_file = doc.placedItems[i].file;
                                                out_file = File(assets_folder+"/"+in_file.name);
                                                in_file.copy(out_file);
                                                doc.placedItems[i].file = out_file;
                                           }
                                           for (i=0;i<doc.rasterItems.length;i++) {
                                                if (doc.rasterItems[i].embedded) continue;
                                                in_file = doc.rasterItems[i].file;
                                                out_file = File(assets_folder+"/"+in_file.name);
                                                in_file.copy(out_file);
                                                doc.rasterItems[i].file = out_file;
                                           }
                                           
                                           // save as new Illustrator file
                                           packaged_file = File(export_folder + "/" + filename + FILE_SUFFIX + extension);
                                           doc.saveAs(packaged_file, this.getAIOptions() );
                                           
                                           // PDF export
                                          var pdf_target_file = File(export_folder + "/" + this.changeExtension(doc.name, ".pdf"));
                                          doc.saveAs( pdf_target_file, this.getPDFOptions() );
                                          
                                           // EPS export
                                           var eps_target_file = File(export_folder + "/" + this.changeExtension(doc.name, ".eps"));
                                           doc.saveAs( eps_target_file, this.getEPSOptions() );
                                           
                                           // close the document and re-open the original file
                                           doc.close();
                                           app.open(File(original_file));
                                           
                                      } else {
                                           alert("Unable to create the assets folder.");
                                      }
                                      
                                      function getAIOptions() {
                                           var options = new IllustratorSaveOptions();
                                           options.embedICCProfile = true;
                                           options.pdfCompatible = false;
                                           return options;
                                      }
                                           
                                      function getEPSOptions() {
                                           var options = new EPSSaveOptions();
                                           options.cmykPostScript = true;
                                           options.embedAllFonts = true;
                                           return options;
                                      }
                                      
                                      function getPDFOptions() {
                                           var options = new PDFSaveOptions();
                                          options.pDFPreset = "[Smallest File Size]";
                                           
                                          options.compatibility = PDFCompatibility.ACROBAT7;
                                          // general
                                          options.preserveEditability = false;
                                          options.generateThumbnails = false;
                                          options.optimization = true;
                                          options.viewAfterSaving = false;
                                          options.acrobatLayers = false;
                                          // compression
                                          options.compressArt = true;
                                          options.colorCompression = CompressionQuality.AUTOMATICJPEGMEDIUM;
                                          
                                           return options;
                                      }
                                      
                                      function changeExtension(filename, new_ext) {
                                          var new_name = "";
                                           if (filename.indexOf('.') < 0) {
                                                new_name = filename + new_ext;
                                           } else {
                                                var dot = filename.lastIndexOf('.');
                                                new_name += filename.substring(0, dot);
                                                new_name += new_ext;
                                           }
                                          return new_name;
                                      }
                                      
                                      
                                      • 16. Re: Ai Packaging Script
                                        fuzzyteddy Community Member

                                        Hi pwever,

                                         

                                        Thanks for creating the script for me... unfortunately my pc can't seem to run the javascript file but it runs visual basic scripts. Is there a way you can convert the current script to visual basic for me? You'd would be doing me a huge favour and I thank you in advance if you're free to help me

                                        • 17. Re: Ai Packaging Script
                                          Muppet Mark Community Member

                                          What are you doing with the file…? The syntax is ExtendScript and should run on both platforms… At a glance I can't see anything that may be OS specific… IMO better to sort any issue than translate…

                                          • 18. Re: Ai Packaging Script
                                            fuzzyteddy Community Member

                                            Hi pwever,

                                             

                                            Sorry, I copied the text wrongly... and totally missed the download link you posted... I've downloaded the file and it works perfectly.. Sorry for troubling you and Thanks a million for helping me with this script!

                                            • 19. Re: Ai Packaging Script
                                              Muppet Mark Community Member

                                              That was easier me thinks… You can C&P from the forum but you need to save in plain text depending on what you use… AI will not see *.jsxbin