Write used color swatch names as text on the artboard
Below is a a script that I found in hopes that it would be able to take all of the "used swatches" in the file and write a list of their swatch names in a text box. I work in the Sublimation apparel industry and it would be very useful for art approval documents. The script I found below does not work. I have little to no knowledge on how to edit or customize it to work the way I'd like it to.
Any advice, editing, creating of the script so I can download it... would be much appreciated.
Thanks in advance!
// https://community.adobe.com/t5/illustrator-discussions/write-used-color-swatch-names-as-text-on-the-artboard/m-p/9487666#M73128
function usedSwatches() {
if (app.documents.length == 0) {
return;
} else {
var docRef = app.activeDocument;
var docW = docRef.width;
var docH = docRef.height;
var sL = docRef.swatches;
var text = '';
for (var i = 0; i < sL.length; i++) {
if (sL[i].name != '[None]' && sL[i].name != '[Registration]') {
text += sL[i].name + '\r';
}
}
var aP = docRef.pathItems.rectangle(docH, 0, docW / 2, docH, true);
var tF = docRef.textFrames.areaText(aP);
tF.contents = text;
}
}
usedSwatches();