SetColor
Sets the text color to the current text Range.
Syntax
expression.SetColor(color);
expression - A variable that represents a ApiRange class.
Parameters
| Name | Required/Optional | Data type | Default | Description |
|---|---|---|---|---|
| color | Required | ApiColor | No description provided. |
Returns
ApiRange | null
Example
This example sets the text color to the text Range.
- Code
- Result
// How to color the text of the range.
// Set the text color to middle washed rose.
const doc = Api.GetDocument();
const firstParagraph = doc.GetElement(0);
firstParagraph.AddText('ONLYOFFICE Document Builder');
const companyRange = doc.GetRange(1, 11);
companyRange.SetColor(Api.HexColor('#FF6F3D'));
const productRange = doc.GetRange(12, 30);
const themeColor = Api.ThemeColor('accent1');
productRange.SetColor(themeColor);