AddElement
按段落在单元格中的位置添加段落。
语法
expression.AddElement(oCell, nPos, oElement);
expression - 表示 ApiTable 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| oCell | 必需 | ApiTableCell | 将添加指定元素的单元格。 | |
| nPos | 必需 | number | 将添加指定元素的单元格中的位置。 | |
| oElement | 必需 | DocumentElement | 将在当前位置添加的文档元素。 |
返回值
boolean
示例
在 PDF 中的表格单元格内的特定位置添加段落。
// Insert a document element into a specific cell of a table in a PDF.
// Create a table and add a paragraph as the first element of its first cell in a PDF.
const doc = Api.GetDocument();
const page = doc.GetPage(0);
const table = Api.CreateTable(2, 2);
page.AddObject(table);
const cell = table.GetCell(0, 0);
const paragraph = Api.CreateParagraph();
paragraph.AddText('Inserted paragraph');
table.AddElement(cell, 0, paragraph);