跳到主要内容

CreateWordArt

使用指定的参数创建艺术字对象。

语法

expression.CreateWordArt(oTextPr, sText, sTransform, oFill, oStroke, nRotAngle, nWidth, nHeight, nIndLeft, nIndTop);

expression - 表示 Api 类的变量。

参数

名称必需/可选数据类型默认值描述
oTextPr可选ApiTextPrApi.CreateTextPr()文本属性。
sText可选string"Your text here"艺术字对象的文本。
sTransform可选TextTransform"textNoShape"文本变换类型。
oFill可选ApiFillApi.CreateNoFill()用于填充艺术字对象的颜色或图案。
oStroke可选ApiStrokeApi.CreateStroke(0, Api.CreateNoFill())用于创建艺术字对象阴影的笔触。
nRotAngle可选number0旋转角度。
nWidth可选EMU1828800以英制度量单位度量的艺术字宽度。
nHeight可选EMU1828800以英制度量单位度量的艺术字高度。
nIndLeft可选EMUApiPresentation.GetWidth() / 2以英制单位测量的艺术字左侧缩进值。
nIndTop可选EMUApiPresentation.GetHeight() / 2以英制单位测量的艺术字顶部缩进值。

返回值

ApiDrawing

示例

此示例使用 "textArchUp" 文本变换类型创建艺术字对象。

// How to create word art indicating its text properties.

// Add arch up text word art.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();

const run = Api.CreateRun();
const textPr = run.GetTextPr();
textPr.SetFontSize(72);
textPr.SetBold(true);
textPr.SetCaps(true);
textPr.SetColor(Api.HexColor('#333333'));
textPr.SetFontFamily("Comic Sans MS");
const fill = Api.CreateSolidFill(Api.RGB(255, 111, 61));
const stroke = Api.CreateStroke(1 * 36000, Api.CreateSolidFill(Api.RGB(51, 51, 51)));
const textArt = Api.CreateWordArt(textPr, "onlyoffice", "textArchUp", fill, stroke, 0, 100 * 36000, 30 * 36000);
slide.AddObject(textArt);