Skip to main content
Participant
September 9, 2022
Answered

SVG to AI

  • September 9, 2022
  • 1 reply
  • 288 views

Hi guys how are you?

My script reads an SVG file and converts it to an AI file. So far everything is working, but I need this AI file to be in CMYK color mode. Currently the AI files are being generated in RGB format. Does anyone have any suggestions to solve this problem?

 

....

var inputFolder = Folder.selectDialog ("Select a folder to process...");

if (inputFolder != null){
var fileandfolderAr = scanSubFolders(inputFolder, /\.(svg)$/i);
var fileList = fileandfolderAr[0];
}
for (var i=fileList.length-1; i>=0; i--){
app.open(fileList[i]);
var doc = app.activeDocument;

var fn = doc.fullName.toString();
var docName = fn.substring(fn.lastIndexOf("/")+1,fn.length).replace(/\.[svg]{2,3}/i,"");
var savePath = fn.substring(0,fn.lastIndexOf("/")+1);

var ext;
try{

 

//save the ai file:
ext = ".ai";
doc.saveAs(File(savePath + docName + ext));
doc.close(SaveOptions.DONOTSAVECHANGES);

} catch(e){
alert('Erro: " ' + doc.name + '" failed.\n' + e.message);
return;
}

.......

 

 

This topic has been closed for replies.
Correct answer CarlosCanto

add the following line after opening the file

 

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

1 reply

CarlosCanto
Community Expert
CarlosCantoCommunity ExpertCorrect answer
Community Expert
September 9, 2022

add the following line after opening the file

 

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