Skip to main content

SetColor

Sets the text color to the current text run in the RGB format.

Syntax

expression.SetColor(r, g, b, isAuto);

expression - A variable that represents a ApiTextPr class.

Parameters

NameRequired/OptionalData typeDefaultDescription
rRequiredbyteRed color component value.
gRequiredbyteGreen color component value.
bRequiredbyteBlue color component value.
isAutoOptionalbooleanfalseIf this parameter is set to "true", then r,g,b parameters will be ignored.

Returns

ApiTextPr

Example

This example sets the text color for the current text run in the RGB format.

let doc = Api.GetDocument();
let textPr = doc.GetDefaultTextPr();
textPr.SetColor(255, 111, 61, false);
let paragraph = doc.GetElement(0);
paragraph.AddText("A sample text with the color set to orange using the text properties.");