跳到主要内容

AddObject

向页面添加可用对象。

语法​

expression.AddObject(object);

expression - 表示 ApiPage 类的变量。

参数​

名称必需/可选数据类型默认值描述
object必需FloatObject要添加到页面的批注、字段或绘图。

返回值​

FloatObject

示例​

在 PDF 的页面上插入视觉元素。

// Useful for adding content to the page in a PDF.

// Place a chart or shape on the current page in a PDF.

const doc = Api.GetDocument();
doc.AddPage(0);
const page = doc.GetPage(0);

const chart = Api.CreateChart("3DColumnClustered", [
[200, 240, 280],
[250, 260, 280]
], ["Projected Revenue", "Estimated Costs"], [2014, 2015, 2016], 4051300, 2347595, 24);
chart.SetVerAxisTitle("USD In Hundred Thousands", 20);
chart.SetHorAxisTitle("Year", 22);
chart.SetLegendPos("bottom");
chart.SetShowDataLabels(false, false, true, false);
chart.SetTitle("Financial Overview", 26);
chart.SetSize(150 * 36000, 65 * 36000);
chart.SetPosition(608400, 1267200);

let fill = Api.CreateSolidFill(Api.RGB(51, 51, 51));
chart.SetSeriesFill(fill, 0, false);
fill = Api.CreateSolidFill(Api.RGB(255, 111, 61));
chart.SetSeriesFill(fill, 1, false);
page.AddObject(chart);