Information Classification: External Restricted.
See https://www.chili-publish.com/security

Working with Colors in Javascript

Create a new cmyk color with Javascript

//C=cyan, M=Magento, Y=Yellow, K=Black
var newColor = editor.ExecuteFunction("document.colors", "Add");
  editor.SetProperty("document.colors[" + newColor.id + "]","name","mycolor");
  editor.SetProperty("document.colors[" + newColor.id + "]","type","CMYK");
  editor.SetProperty("document.colors[" + newColor.id + "]","c","100");
  editor.SetProperty("document.colors[" + newColor.id + "]","m","0");
  editor.SetProperty("document.colors[" + newColor.id + "]","y","0");
  editor.SetProperty("document.colors[" + newColor.id + "]","k","0");

Create a new RGB color with Javascript

var newColor = editor.ExecuteFunction("document.colors", "Add");
  editor.SetProperty("document.colors[" + newColor.id + "]","name","myrgbcolor");
  editor.SetProperty("document.colors[" + newColor.id + "]","type","RGB");
  editor.SetProperty("document.colors[" + newColor.id + "]","r","100");
  editor.SetProperty("document.colors[" + newColor.id + "]","g","200");
  editor.SetProperty("document.colors[" + newColor.id + "]","b","0");

Set a Color Value

//change a cmyk color
editor.SetProperty('document.colors[Name_Or_ID]','k','75');
//change a RGB color
editor.SetProperty("document.colors[Name_Or_ID]","r","100");

Setting a Frame's Border and Fill Color

// change the hasBorder and hasFill attribute
editor.SetProperty('document.selectedFrame','hasBorder','true');
editorObject.SetProperty('document.allFrames[Tag_Or_ID]','hasFill','true');
 
//change the fill color
 color = editor.GetObject('document.colors[Name_Or_ID].javaScriptDescriptor');
editor.SetProperty('document.selectedFrame','fillColor',color);
 
//change the border color
color = editorObject.GetObject('document.colors[Name_Or_ID].javaScriptDescriptor');
editorObject.SetProperty('document.allFrames[Tag_Or_ID]','borderColor',color);

Assign a New Color to a Text Frame

Assigning a new color to a text frame, The JS function ImportTextFlow can be used. You will need to provide the HTML hex value of the color (reflect in the editor for display) , and the color id for the color (for PDF output).

editorObject.ExecuteFunction("document.selectedFrame", 'ImportTextFlow', '<p fontFamily="Arial_Regular"><span fontSize="20" color="#00adee" my_color="B15C081B-C3C9-4CCD-814F-F29B4A2A7BDD">Insert Your Text Here</span></p>');

Change Selected Text's color

//Get color by name ex. get color named blue
var color = editorObject.GetObject('document.colors[blue].javaScriptDescriptor');


//apply this color to the selected text
editorObject.SetProperty('document.selectedText.textFormat','color',color);

All information on this page must be treated as External Restricted, or more strict. https://www.chili-publish.com/security