illustrator插件--常用功能开发--移除非纯黑叠印--js脚本开发--AI插件

开发一款可用于移除非纯黑叠印属性的插件,以下功能仅用于学习交流,请勿用于非法用途和商业用途,源代码如下所示:

var doc = documents[0];
var pgItm = doc.pageItems;
app.selection = null;
for (var i = 0; i < pgItm.length; i += 1) {
    if (pgItm[i].typename == "TextFrame") {
        var fiTxtColor = pgItm[i].textRange.fillColor;
        if (pgItm[i].textRange.overprintFill == true) {
            if (fiTxtColor.black == 100 && fiTxtColor.cyan == 0 && fiTxtColor.magenta == 0 && fiTxtColor.yellow == 0) {
                continue;
            } else {
                pgItm[i].selected = true;
            }
        }
    } else {
        var fiColor = pgItm[i].fillColor;
        if (pgItm[i].fillOverprint == true) {
            if (fiColor.black == 100 && fiColor.cyan == 0 && fiColor.magenta == 0 && fiColor.yellow == 0) {
                continue;
            } else {
                pgItm[i].selected = true;
            }
        }
    }
}
removeOVPfill(app.selection);
app.selection = null;
for (var i = 0; i < pgItm.length; i += 1) {
    if (pgItm[i].typename == "TextFrame") {
        var stTxtColor = pgItm[i].textRange.strokeColor;
        if (pgItm[i].textRange.overprintStroke == true) {
            if (stTxtColor.black == 100 && stTxtColor.cyan == 0 && stTxtColor.magenta == 0 && stTxtColor.yellow == 0) {
                continue;
            } else {
                pgItm[i].selected = true;
            }
        }
    } else {
        var stColor = pgItm[i].strokeColor;
        if (pgItm[i].strokeOverprint == true) {
            if (stColor.black == 100 && stColor.cyan == 0 && stColor.magenta == 0 && stColor.yellow == 0) {
                continue;
            } else {
                pgItm[i].selected = true;
            }
        }
    }
}
removeOVPstroke(app.selection);

function removeOVPfill(sel) {
    if (sel.length == 0) {
        return;
    }
    c = confirm("删除填充叠印?", false, "Paint");
    if (c == true) {
        for (var i = 0; i < sel.length; i += 1) {
            sel[i].fillOverprint = false;
            try {
                sel[i].textRange.overprintFill = false;
            } catch (e) {

            }
            sel[i].selected = false;
        }
    }
}

function removeOVPstroke(sel) {
    if (sel.length == 0) {
        return;
    }
    c = confirm("删除描边叠印?", false, "Does not");
    if (c == true) {
        for (var i = 0; i < sel.length; i += 1) {
            sel[i].strokeOverprint = false;
            try {
                sel[i].textRange.overprintStroke = false;
            } catch (e) {

            }
            sel[i].selected = false;
        }
    }
}

图片.png

你可能感兴趣的:(illustrator插件--常用功能开发--移除非纯黑叠印--js脚本开发--AI插件)