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!
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.");
}
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
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;
}
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 ![]()
North America
Europe, Middle East and Africa
Asia Pacific