0
我很拼命地为我的问题寻找解决方案,我需要在InDesign中放置大量的内联图形,但对于某些原因是它不工作我对Javascript的知识非常贫乏,我的时间不多了,所以我不能花太多时间学习JS。我正在使用优胜美地在iMac上使用InDesign CC2014。f [i] .insertionPoints [0] .rectangles.add({geometricBounds:
以下错误消息弹出式:
错误扣:
如果有人给我一个提示,我会很高兴。
main();
function main() {
var name, f, file, text,
arr = [];
if(app.documents.length != 0) {
var doc = app.activeDocument;
var folder = Folder.selectDialog("Choose a folder with images");
if (folder != null) {
app.findObjectPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.findWhat = "@[email protected]";
f = doc.findGrep(true);
for (i = 0; i < f.length; i++) {
name = f[i].contents.replace(/@/g, "");
file = new File(folder.fsName + "/" + name);
if (file.exists) {
f[i].contents = "";
var rect = f[i].insertionPoints[0].rectangles.add({geometricBounds:[0,0, 60, 40.667 ]});
\t \t \t \t rect.place (file);
\t \t \t \t rect.fit (FitOptions.FRAME_TO_CONTENT);
}
else {
arr.push("File doesn't exist '" + name + "'");
}
}
app.findObjectPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
arr.push("------------------------------------------");
text = arr.join("\r");
writeToFile(text);
}
}
else{
alert("Please open a document and try again.");
}
}
function writeToFile(text) {
var file = new File("~/Desktop/Place inline images.txt");
if (file.exists) {
file.open("e");
file.seek(0, 2);
}
else {
file.open("w");
}
file.write(text + "\r");
file.close();
}
或者使用try/catch子句。 –
感谢您的回复。是的,这是问题,它不能代替已经被删除或清空的东西。它帮助了很多。 – alejorojas2k