跳到主要内容

AddText

向当前段落添加文本。

语法​

expression.AddText(text, widths);

expression - 表示 ApiParagraph 类的变量。

参数​

名称必需/可选数据类型默认值描述
text必需string | number[]要插入到当前文档元素中的文本。可以是字符串或 Unicode 码位数组。
widths可选number[]字符宽度数组(以毫米为单位)。其长度应与 "text" 参数中传递的码位数组相同。指定宽度后,添加的字符将严格保持这些宽度。

返回值​

ApiRun

示例​

向文档中的现有段落添加文本。

// How do I insert a text string into a paragraph in a document?

// Place custom text inside a paragraph to build document content in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("This is just a sample text. Nothing special.");