Get Started
Documentation

SetColor

SetColor(r, g, b, isAutoopt)

Inherited From:

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

Parameters:

Name Type Attributes Default Description
r byte Red color component value.
g byte Green color component value.
b byte Blue color component value.
isAuto boolean <optional> false If this parameter is set to "true", then r,g,b parameters will be ignored.

Example

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

Resulting document