• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
8

Alert + list to RGB colors (InDesign)

Explorer ,
Oct 22, 2023 Oct 22, 2023

Copy link to clipboard

Copied

Hey everyone!

I work with documents (indesign) that are intended for printing. Therefore, my color swatches should be in CMYK format. I have the code to convert RGB colors to CMYK, but I was looking for something more elaborate.

I would like a script that can scan my document and identify any RGB color swatches. If any RGB swatches are found, the script should generate a window with a list of the offending colors. Finally, the script should prompt me with a YES or NO option to convert the colors to CMYK.

Can anyone help me with this?

The code to convert:

 

app.menuActions.item("$ID/Add All Unnamed Colors").invoke();
var myIndesignDoc = app.activeDocument;
var myUnusedSwatches = myIndesignDoc.unusedSwatches;
for (var s = myUnusedSwatches.length-1; s >= 0; s--) {
var mySwatch = myIndesignDoc.unusedSwatches[s];
var name = mySwatch.name;
if (name != ""){
mySwatch.remove();
}
}
app.activeDocument.colors.everyItem().properties = {space:ColorSpace.CMYK, model:ColorModel.PROCESS};

 

TOPICS
Feature request , How to , Scripting

Views

291

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 22, 2023 Oct 22, 2023

I work with documents (indesign) that are intended for printing.

 

Hi @eusoujp , Are you delivering a print ready PDF to the printer? If that’s the case you don’t need a script, an Export to PDF/X-4 or X-1a  with the Output Destination set to Document CMYK will convert all of the native RGB and Lab color to the document’s assigned CMYK space:

 

Screen Shot 32.png

 

The export PDF/X-4 is all DeviceCMYK:

 

 

Screen Shot 33.png

 

No RGB Objects

 

 

Screen Shot 34.png

Votes

Translate

Translate
Community Expert ,
Oct 22, 2023 Oct 22, 2023

Copy link to clipboard

Copied

I work with documents (indesign) that are intended for printing.

 

Hi @eusoujp , Are you delivering a print ready PDF to the printer? If that’s the case you don’t need a script, an Export to PDF/X-4 or X-1a  with the Output Destination set to Document CMYK will convert all of the native RGB and Lab color to the document’s assigned CMYK space:

 

Screen Shot 32.png

 

The export PDF/X-4 is all DeviceCMYK:

 

 

Screen Shot 33.png

 

No RGB Objects

 

 

Screen Shot 34.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 23, 2023 Oct 23, 2023

Copy link to clipboard

Copied

Hi Rob. Thanks for the answer. I work for print. However, what I'm after is simpler. It doesn't always happen, but there are documents in which there may be color samples in RGB format. But before I could convert the color from RGB to CMYK, I would like to be shown a window with the list of RGB colors that are present in the document (if the document finds any RGB colors). And in that same window I could choose whether or not I want to convert to CMYK.
I appreciate your answers and I also think it will be helpful. But I would like a script with the above information - it is important too.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 24, 2023 Oct 24, 2023

Copy link to clipboard

Copied

LATEST

Still not sure you need to build a script with a dialog—that functionality is built into the Swatches panel. You can Command click to select the panel’s RGB swatches (the List view includes a space icon in the last column), then double click to change all the color’s spaces:

 

Screen Shot 56.pngScreen Shot 57.png

 

If you want to convert all of the document native unnamed Colors and named Swatches to CMYK, this would work:

 

 

var c = app.activeDocument.colors.everyItem().getElements()
for (var i = 0; i < c.length; i++){
    try {c[i].space = ColorSpace.CMYK}catch(e) {} 
};   

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines