Copy link to clipboard
Copied
Could you detect a problem here? The document swatches pallete contains spot color named PANTONE 1945 C, newetherless I get the error here. Spots listing prints the same name as in the spotName. What did I miss?
alert(spotName); //PANTONE 1945 C
try {
doc.spots.getByName(spotName);
} catch (e) {
alert('Spot not found');
$.writeln("---------");
var spots = doc.spots;
for (var i = 0; i < spots.length; i++) {
$.writeln(spots[i].name); //PANTONE 1945 C
}
$.writeln("---------");
return;
}
The above situation occurs when a color has been added from the pantone library to the swatch palette. If I create a spot color through "New Swatch" with the name "PANTONE 1945 C" then the error will go away, any thoughts?
p.s. What is the reason that the code highlighting is present in the edit window, but is not shown when published in this post?
Hi @Charu Rajput as it turned out the spotName value didn't come in UTF-8 encoding.
Copy link to clipboard
Copied
Hi
@fastwind - Not sure if you have declared all variables in your script, please try below version if that works and if works, try to integrate in your workflow
var spotName = "PANTONE 1945 C";
alert(spotName);
var doc = app.activeDocument;
var spots = doc.spots;
try {
doc.spots.getByName(spotName);
for (var i = 0; i < spots.length; i++) {
alert(spots[i].name);
}
} catch (e) {
alert('Spot not found');
}
Copy link to clipboard
Copied
Hi @Charu Rajput as it turned out the spotName value didn't come in UTF-8 encoding.
Copy link to clipboard
Copied
@fastwind - Could you please posta. screenshot what excatly you are getting after running the above script?
Copy link to clipboard
Copied
@Charu Rajput already fixed...