Skip to main content

SetBackgroundColor

Sets the background color to the current content control.

Syntax

expression.SetBackgroundColor(color);

expression - A variable that represents a ApiBlockLvlSdt class.

Parameters

NameRequired/OptionalData typeDefaultDescription
colorOptionalApiColorThe background color.

Returns

boolean

Example

Set the background color for the block-level container in a document.

// How can I set background color using a block-level content control in a document?

// Set background color for a block-level content control in a document.

let doc = Api.GetDocument();
let blockLvlSdt = Api.CreateBlockLvlSdt();
blockLvlSdt.SetBackgroundColor(Api.RGBA(0, 0, 255, 40));
blockLvlSdt.GetContent().GetElement(0).AddText("This is a block text content control with a blue transparent background.");
doc.AddElement(0, blockLvlSdt);