Skip to main content

GetTextSize

Gets widget text size. 💡 Text size === 0 means autofit

Inherited from ApiBaseWidget.GetTextSize.

Example

Get the text size of a field widget in a PDF.

// How do I retrieve the text size for a widget in a PDF?

// Display the text size value for a widget in a PDF.

let doc = Api.GetDocument();
let page = doc.GetPage(0);
let textField = Api.CreateTextField([10, 10, 160, 30]);
page.AddObject(textField);

textField.AddWidget(0, [10, 40, 160, 60]);
let widgets = textField.GetAllWidgets();
widgets.forEach(function(widget) {
widget.SetTextSize(15);
});
let textSize = widgets[0].GetTextSize();
textField.SetValue('Text size is: ' + textSize);