跳到主要内容

SetColor

Sets the text color to the current paragraph.

Syntax

expression.SetColor(color);

expression - A variable that represents a ApiParagraph class.

Parameters

NameRequired/OptionalData typeDefaultDescription
colorRequiredApiColorNo description provided.

Returns

ApiParagraph

Example

This example sets the text color to the current paragraph.

// Color the paragraph text with orange.

// Get the first paragraph and make its font color orange.

const doc = Api.GetDocument();
const firstParagraph = doc.GetElement(0);
firstParagraph.AddText('This is a paragraph with the font color set to orange.');
firstParagraph.SetColor(Api.HexColor('#FF6F3D'));

const color = Api.HexColor('ff6f3d');
const secondParagraph = Api.CreateParagraph();
secondParagraph.AddText('This text is in same orange color, but created using HexColor method.');
secondParagraph.SetColor(color);
doc.Push(secondParagraph);