Skip to main content
Inspiring
Oct 6, 2024 7:31 PM UTC
Answered

Spot color not found

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?

This topic is closed to new replies. Start a new post to keep the conversation going.
andyf65867865Correct answer
Inspiring
Oct 7, 2024 6:15 AM UTC

Hi @Charu Rajput as it turned out the spotName value didn't come in UTF-8 encoding.

4 replies

Charu Rajput
Community Expert
Community Expert
Oct 6, 2024 8:41 PM UTC

Hi

@andyf65867865 - 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');
}
Translate
Best regards
andyf65867865AuthorCorrect answer
Inspiring
Oct 7, 2024 6:15 AM UTC

Hi @Charu Rajput as it turned out the spotName value didn't come in UTF-8 encoding.

Translate
Charu Rajput
Community Expert
Community Expert
Oct 7, 2024 12:13 PM UTC

@andyf65867865 - Could you please posta. screenshot what excatly you are getting after running the above script?

Translate
Best regards