var doc = app.activeDocument;
var list = [];
for (var i = 0; i < doc.artboards.length; i++) { for (var j = doc.textFrames.length-1; j >=0; j--) { if(doc.textFrames[j].typename == 'TextFrame'){ try { var textShape = doc.textFrames[j];
var tl = textShape.left;
var tr = textShape.left+textShape.width;
var tt = textShape.top;
var tb = textShape.top-textShape.height;
var a = new Artboard(i);
al = a.left;
ar = a.right;
at = a.top;
ab = a.bottom;
if(al<tl){ if(ar>tr){ if(at>tt){ if(ab<tb){ var fillColor = textShape.textRange.strokeColor;
var c =fillColor.cyan;
var m = fillColor.magenta;
var y = fillColor.yellow;
var k = fillColor.black;
var s = c+'-'+m+'-'+y+'-'+k;
if(s == '1.1-99.1-1.1-1.1'){ var content = textShape.contents;
textShape.remove();
content = content.replace('*',' ') list.push(['~/Desktop/1/'+(i+1)+' '+content.replace(/^\s*|\s*$/g,"")+'.pdf',(i+1)])
}
}
}
}
}
}catch (e) {
}
}
}
}
for (var i = 0; i < list.length; i++) { file_save_pdf(list[i][0],"3",list[i][1]);
}
function file_save_pdf(dest,opt,page_index) {
opt = opt==''||opt==undefined?'[Illustrator 默认值]':opt;
saveOpts = new PDFSaveOptions();
saveOpts.pDFPreset = opt;
saveOpts.artboardRange = page_index;
var p = new File(dest).parent;
if(!p.exists){ p.create();
}
doc.saveAs(new File(dest), saveOpts);
}
function Artboard(index) { var doc = app.activeDocument;
index = index == undefined ? doc.artboards.getActiveArtboardIndex() : index
var abBounds = doc.artboards[index].artboardRect;
this.width = abBounds[2] - abBounds[0];
this.height = abBounds[1] - abBounds[3];
this.left = abBounds[0];
this.top = abBounds[1];
this.bottom = abBounds[3];
this.right = abBounds[2];
this.index = index;
this.toString = function () { return '当前是第' + index + '个页面\n页面尺寸为' + this.width / pt + 'x' + this.height / pt + ' mm';
}