TRY NEW VERSION

Try now New API BETA

Try out the new view and capabilities of the API documentation

START

SetColor

SetColor(r, g, b, [isAuto]) → { ApiTextPr }

Sets the text color for the current text run 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
ApiTextPr

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
var oRun = Api.CreateRun();
oRun.AddText("This is just a sample text. ");
oParagraph.AddElement(oRun);
oRun = Api.CreateRun();
oRun.SetColor(255, 111, 61);
oRun.AddText("This is a text run with the font color set to orange.");
oParagraph.AddElement(oRun);
builder.SaveFile("docx", "SetColor.docx");
builder.CloseFile();

Resulting document