跳到主要内容

GetIconXPos

获取按钮控件图标的 x 位置。

语法​

expression.GetIconXPos();

expression - 表示 ApiButtonWidget 类的变量。

参数​

此方法没有任何参数。

返回值​

percentage

示例​

查找 PDF 中按钮控件内图标的水平位置。

// How do I get the X coordinate of an icon in a PDF button?

// Retrieve the icon's left position in a button widget in a PDF.

let doc = Api.GetDocument();
let page = doc.GetPage(0);
let buttonField = Api.CreateImageField([10, 10, 120, 100]);
page.AddObject(buttonField);

let widgets = buttonField.GetAllWidgets();
widgets[0].SetLayout('iconTextV');
widgets[0].SetImage('https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png', 'normal');
widgets[0].SetLabel('Icon X position is: ' + widgets[0].GetIconXPos());