跳到主要内容

AddDrawingToPage

将图形添加到指定页面。 💡 此方法可能会稍慢,因为它需要运行文档计算过程以在指定页面上排列表格。

语法

expression.AddDrawingToPage(oDrawing, nPage, x, y);

expression - 表示 ApiDocument 类的变量。

参数

名称必需/可选数据类型默认值描述
oDrawing必需ApiDrawing要添加到页面的图形。
nPage必需number页面索引。
x必需EMU以英制单位表示的 X 坐标。
y必需EMU以英制单位表示的 Y 坐标。

返回值

boolean

示例

此示例展示如何获取给定绝对页面上的表格集合。

// How to add the drawing to the document.

// Create an image from the URL and insert it to the page.

let doc = Api.GetDocument();
let drawing = Api.CreateImage(
'https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png',
60 * 36000, 60 * 36000
);
let paragraph = Api.CreateParagraph();
paragraph.AddPageBreak();
doc.Push(paragraph);
doc.AddDrawingToPage(drawing, 1, 50 * 36000, 50 * 36000);