这个将每一层导出到带有选项的 eps。隔离函数 saveEPS ,我想这就是你需要的。
var doc = app.activeDocument;
var docname = (doc.name.split('.'))[0]; // name
var doc_artboard = doc.artboards[0].artboardRect;
if (app.documents.length > 1) {
alert( "Nur ein Dokument darf geöffnet sein. Schließen Sie andere Dokumente und führen Sie das Script erneut aus.");
} else {
var ok = confirm( "Bitte speichern Sie zuerst Ihr Original.\nDie Ebenen werden im gleichen Ordner wie Ihre Datei gespeichert.\nWeiter?" );
if (ok) {
// prepare layers
for(var i=0; i<doc.layers.length; i++) {
doc.layers[i].visible = false;
}
// go through each layers
for(var i=0; i<doc.layers.length; i++) {
app.activeDocument = doc;
if (i>0) doc.layers[i-1].visible = false;
doc.layers[i].visible = true;
doc.activeLayer = doc.layers[i];
saveEPS( doc.path, doc.activeLayer.name, i );
}
// close original file without saving
doc.close( SaveOptions.DONOTSAVECHANGES );
}
}
function saveEPS( path, name, id ) {
var currlayer = doc.layers[id];
var g = currlayer.groupItems.add();
group( g, currlayer.pageItems );
var t = g.top;
var l = g.left;
var w = doc.width;
var h = doc.height;
/*
var w = 31.1*2.834645;
var h = 28.15*2.834645;
*/
var myPreset = new DocumentPreset;
myPreset.width = w;
myPreset.height = h;
myPreset.units = RulerUnits.Millimeters;
myPreset.title = docname;
var newdoc = documents.addDocument( "Druck", myPreset);
/*
var newdoc = app.documents.add ( doc.documentColorSpace, doc.width, doc.height, 1,
DocumentArtboardLayout.Row, 72);
*/
newdoc.artboards[0].artboardRect = doc_artboard;
var newlayer = newdoc.layers[0];
g.duplicate( newlayer, ElementPlacement.PLACEATBEGINNING );
newlayer.pageItems[0].top = t;
newlayer.pageItems[0].left = l;
path.changePath( name+".eps" );
var saveOpts = new EPSSaveOptions();
saveOpts.compatibility = Compatibility.ILLUSTRATOR16;
saveOpts.embedLinkedFiles = true;
saveOpts.includeDocumentThumbnails = true;
saveOpts.embedAllFonts = true;
saveOpts.saveMultipleArtboards = false;
saveOpts.cmykPostScript = true;
saveOpts.preview = EPSPreview.TRANSPARENTCOLORTIFF;
newdoc.saveAs( path, saveOpts );
newdoc.close( SaveOptions.DONOTSAVECHANGES );
// wait for the new file to save and close before continue.
// A callback function (if possible) will be better than a while loop for sure.
while (app.documents.length > 1) {
continue;
}
}
function group( gg, items ) {
var newItem;
for(var i=items.length-1; i>=0; i--) {
if (items[i]!=gg) {
newItem = items[i].move (gg, ElementPlacement.PLACEATBEGINNING);
}
}
return newItem;
}