illustrator插件--常用功能开发--链接文件打包--js脚本开发--AI插件

  illustrator是矢量编辑软件,画板是绘制处理的重要容器,在印刷方面的一个重要功能就是链接文件打包,开发一个链接文件打包功能,以下功能仅用于学习交流,请勿用于非法用途和商业用途,源代码如下所示:


var doc = app.activeDocument;
var thePlacedItems = doc.placedItems;
var theRasterItems = doc.rasterItems;
var linksfolder = "ai打包文件";
var imagesfolder = "/" + linksfolder + "/";
var docName = "/" + doc.name;
var preselectedFolder = "/d/Паша/";
var strSaveDialog = "请选择要保存链接图的存放磁盘或文件夹";
var start = true;
var ver = 12;
var saveOptions = new IllustratorSaveOptions();
switch (ver) {
    case 3:
        saveOptions.compatibility = Compatibility.ILLUSTRATOR3;
        break;
    case 8:
        saveOptions.compatibility = Compatibility.ILLUSTRATOR8;
        break;
    case 9:
        saveOptions.compatibility = Compatibility.ILLUSTRATOR9;
        break;
    case 10:
        saveOptions.compatibility = Compatibility.ILLUSTRATOR10;
        break;
    case 11:
        saveOptions.compatibility = Compatibility.ILLUSTRATOR11;
        break;
    case 12:
        saveOptions.compatibility = Compatibility.ILLUSTRATOR12;
        break;
}
saveOptions.overprint = PDFOverprint.PRESERVEPDFOVERPRINT;
if (ver <= 9) {
    saveOptions.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;
}
if (ver >= 7) {
    saveOptions.embedLinkedFiles = false;
}
if (ver >= 9) {
    saveOptions.fontSubsetThreshold = 100;
    saveOptions.embedICCProfile = false;
}
if (ver >= 10) {
    saveOptions.compressed = true;
    saveOptions.pdfCompatible = false;
}
if (documents.length > 0) {
    if (doc.saved == false) {
        alert("必须先保存文件!!!", "链接文件打包工具", true);
        start = false;
    }
    if (start) {
        var destFolder = Folder.selectDialog(strSaveDialog, preselectedFolder);
        if (destFolder != null) {
            var folder = new Folder(destFolder);
            folder.create();
            imagesfolder = destFolder + imagesfolder;
            var folder = new Folder(imagesfolder);
            folder.create();
            for (var i = 0; i < thePlacedItems.length; i += 1) {
                source = thePlacedItems[i].file.fullName;
                newSource = new File(source);
                target = imagesfolder + thePlacedItems[i].file.name;
                if (newSource != null) {
                    newSource.copy(target)
                }
                newTarget = new File(target);
                thePlacedItems[i].file = newTarget;
            }
            targetFile = destFolder + docName;
            var saveName = new File(targetFile);
            doc.saveAs(saveName, saveOptions);
        }
    }
}


  合理的脚本代码可以有效的提高工作效率,减少重复劳动。

文章引用至 作者知了-联系方式1

文章引用至 作者知了-联系方式2

你可能感兴趣的:(illustrator插件--常用功能开发--链接文件打包--js脚本开发--AI插件)