Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Ai Packaging Script

Explorer ,
Apr 11, 2012 Apr 11, 2012

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!

TOPICS
Scripting
16.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Apr 11, 2012 Apr 11, 2012

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

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 11, 2012 Apr 11, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2012 Apr 11, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 11, 2012 Apr 11, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2012 Apr 11, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 11, 2012 Apr 11, 2012

Nope, that didn't fix it. 😕

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 19, 2012 Apr 19, 2012

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.file;

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

                    in_file.copy(out_file);

                    doc.placedItems.file = out_file;

          }

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

                    if (doc.rasterItems.embedded) continue;

                    in_file = doc.rasterItems.file;

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

                    in_file.copy(out_file);

                    doc.rasterItems.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.");

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 19, 2012 Apr 19, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 09, 2012 May 09, 2012

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 09, 2012 May 09, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 09, 2012 May 09, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 25, 2012 Jun 25, 2012

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 13, 2012 Aug 13, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 24, 2012 Aug 24, 2012

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.file;
          out_file = File(assets_folder+"/"+in_file.name);
          in_file.copy(out_file);
          doc.placedItems.file = out_file;
     }
     for (i=0;i<doc.rasterItems.length;i++) {
          if (doc.rasterItems.embedded) continue;
          in_file = doc.rasterItems.file;
          out_file = File(assets_folder+"/"+in_file.name);
          in_file.copy(out_file);
          doc.rasterItems.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;
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 29, 2012 Aug 29, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Aug 29, 2012 Aug 29, 2012

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…

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 29, 2012 Aug 29, 2012

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Aug 29, 2012 Aug 29, 2012
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 09, 2012 May 09, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines