Get Started
Documentation

SetHighlight

SetHighlight(r, g, b, isNoneopt)

Specify a highlighting color in the RGB format which is applied as a background for the contents of the current run.

Parameters:

Name Type Attributes Default Description
r byte Red color component value.
g byte Green color component value.
b byte Blue color component value.
isNone 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.SetHighlight(255, 255, 0, false);
oParagraph = oDocument.GetElement(0);
oParagraph.AddText("A sample text highlighted with yellow color using the text properties.");
builder.SaveFile("docx", "SetHighlight.docx");
builder.CloseFile();

Resulting document