Skip to main content
Inspiring
May 6, 2020
Answered

Change DocumentColorSpace to RGB via Javascript

  • May 6, 2020
  • 1 reply
  • 2397 views

Hi,

I have a Javascript Problem. I created a script that exports an vector icon in different formats, for print (eps and ai) and for web (png and svg). My Original DocumentColorSpace is CMYK.

 

When I export the web files the colors deviate from what I defined in the file, because the DocumentColorSpace is still CMYK and not RGB. I can only change it if I create a new document. Is there another way?

 

var grey = new RGBColor();
grey.red = 124;
grey.green = 131;
grey.blue = 132;

var param = bks.name.split('.');
realDocName = param[0];
file = preffix+filepreffix+realDocName+'_grau'+suffix;
folder = preffix+foldername;
var f = new Folder(bks.path + "/" + folder);
if (!f.exists)
f.create();
var saveName = new File ( f + "/" + file );
bks.exportFile(saveName, type, optionsSVG);
bks.close(SaveOptions.DONOTSAVECHANGES);
bks = null;
app.open (fullDocName);
bks = app.activeDocument;
This topic has been closed for replies.
Correct answer Charu Rajput

Hi,

You can change the document color space from CMYK to RGB using following command

app.executeMenuCommand('doc-color-rgb');

 

and from RGB to CMYK using 

app.executeMenuCommand('doc-color-cmyk');

 

Let us know if this helps you.

Thanks

1 reply

Charu Rajput
Community Expert
Charu RajputCommunity ExpertCorrect answer
Community Expert
May 6, 2020

Hi,

You can change the document color space from CMYK to RGB using following command

app.executeMenuCommand('doc-color-rgb');

 

and from RGB to CMYK using 

app.executeMenuCommand('doc-color-cmyk');

 

Let us know if this helps you.

Thanks

Best regards
Inspiring
June 7, 2020

Thank you so much. It worked like a charm.