Get Started
Documentation

SetHighlight

SetHighlight(r, g, b, isNoneopt)

Inherited From:

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, oRun;
oParagraph = oDocument.GetElement(0);
oRun = Api.CreateRun();
oRun.AddText("This is just a sample text. ");
oParagraph.AddElement(oRun);
oRun = Api.CreateRun();
oRun.SetHighlight(255, 255, 0);
oRun.AddText("This is a text run with the text highlighted with yellow color.");
oParagraph.AddElement(oRun);
builder.SaveFile("docx", "SetHighlight.docx");
builder.CloseFile();

Resulting document