Skip to main content
Inspiring
October 6, 2024
Answered

Spot color not found

  • October 6, 2024
  • 1 reply
  • 748 views

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 has been closed for replies.
Correct answer andyf65867865

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

1 reply

Charu Rajput
Community Expert
Community Expert
October 6, 2024

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');
}
Best regards
andyf65867865AuthorCorrect answer
Inspiring
October 7, 2024

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

Inspiring
October 7, 2024

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


@Charu Rajput already fixed...