Get Started
Documentation

SetColor

SetColor(r, g, b, [isAuto]) → { ApiRange | null }

Set the text color for the current text Range in the RGB format.

Parameters:

Name Type Default Description
r byte

Red color component value.

g byte

Green color component value.

b byte

Blue color component value.

isAuto boolean false

If this parameter is set to "true", then r,g,b parameters will be ignored.

Returns:

Type
ApiRange | null

Example

Copy code
builder.CreateFile("docx");
oDocument = Api.GetDocument();
oParagraph = oDocument.GetElement(0);
oParagraph.AddText("ONLYOFFICE Document Builder");
oRange = oDocument.GetRange(0, 24);
oRange.SetColor(255, 164, 101);
builder.SaveFile("docx", "SetColor.docx");
builder.CloseFile();