Highlighted

Change DocumentColorSpace to RGB via Javascript

Explorer ,
May 06, 2020

Copy link to clipboard

Copied

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;
Adobe Community Professional
Correct answer by Charu Rajput | Adobe Community Professional

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

TOPICS
How to, Scripting

Views

552

Likes

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

Change DocumentColorSpace to RGB via Javascript

Explorer ,
May 06, 2020

Copy link to clipboard

Copied

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;
Adobe Community Professional
Correct answer by Charu Rajput | Adobe Community Professional

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

TOPICS
How to, Scripting

Views

553

Likes

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
May 06, 2020 0
Adobe Community Professional ,
May 06, 2020

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
May 06, 2020 2
Explorer ,
Jun 07, 2020

Copy link to clipboard

Copied

Thank you so much. It worked like a charm.

Likes

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
Reply
Loading...
Jun 07, 2020 1
Resources