Get Started
Documentation

SetColor

SetColor(r, g, b, isAutoopt)

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, oTextPr;
oTextPr = oDocument.GetDefaultTextPr();
oTextPr.SetColor(0, 0, 255, false);
oParagraph = oDocument.GetElement(0);
oParagraph.AddText("A sample text with the color set to blue using the text properties.");
builder.SaveFile("docx", "SetColor.docx");
builder.CloseFile();

Resulting document