PDFWidget#

Widgets refer to components which make up form items such as buttons, text inputs and signature fields.

To get the widgets on a page see: getWidgets().

INSTANCE METHODS

getFieldType()#

Return string indicating type of widget.

Returns:

string.

EXAMPLE

var type = widget.getFieldType();
getFieldFlags()#

Return the field flags. Refer to the PDF specification for their meanings.

Returns:

number which determines the bit-field value.

EXAMPLE

var flags = widget.getFieldFlags();
getRect()#

Get the widget bounding box.

Returns:

Rect.

EXAMPLE

var rect = widget.getRect();
setRect(rect: Rect)#

Set the widget bounding box.

Parameters:

rectRect.

EXAMPLE

widget.setRect([0,0,100,100]);
getMaxLen()#

Get maximum allowed length of the string value.

Returns:

number.

EXAMPLE

var length = widget.getMaxLen();
getValue()#

Get the widget value.

Returns:

string.

EXAMPLE

var value = widget.getValue();
setTextValue(value: string)#

Set the widget string value.

Parameters:

valuestring.

EXAMPLE

widget.setTextValue("Hello World!");
setChoiceValue(value: string)#

Sets the choice value against the widget.

Parameters:

valuestring.

EXAMPLE

widget.setChoiceValue("Yes");
toggle()#

Toggle the state of the widget, returns 1 if the state changed.

Returns:

number.

EXAMPLE

var state = widget.toggle();
getOptions()#

Returns an array of strings which represents the value for each corresponding radio button or checkbox field.

Returns:

string[].

EXAMPLE

var options = widget.getOptions();
getLabel()#

Get the field name as a string.

Returns:

string.

EXAMPLE

var label = widget.getLabel();
update()#

Update the appearance stream to account for changes to the widget.

EXAMPLE

widget.update();
isReadOnly()#

If the value is read only and the widget cannot be interacted with.

Returns:

boolean.

EXAMPLE

var isReadOnly = widget.isReadOnly();
isMultiline()#

Returns true if the widget is multiline.

Returns:

boolean.

isPassword()#

Returns true if the widget is a password input.

Returns:

boolean.

isComb()#

Returns true if the widget is a textfield layed out in “comb” style (forms where you write one character per square).

Returns:

boolean.

isButton()#

Returns true if the widget is of “button”, “checkbox” or “radiobutton” type.

Returns:

boolean.

isPushButton()#

Returns true if the widget is of “button” type.

Returns:

boolean.

isCheckbox()#

Returns true if the widget is of “checkbox” type.

Returns:

boolean.

isRadioButton()#

Returns true if the widget is of “radiobutton” type.

Returns:

boolean.

isText()#

Returns true if the widget is of “text” type.

Returns:

boolean.

isChoice()#

Returns true if the widget is of “combobox” or “listbox” type.

Returns:

boolean.

isListBox()#

Returns true if the widget is of “listbox” type.

Returns:

boolean.

isComboBox()#

Returns true if the widget is of “combobox” type.

Returns:

boolean.


Code samples

Code samples are in TypeScript and assume that the following requirements are defined in your TypeScript file header as follows:

import * as fs from "fs"
import * as mupdfjs from "mupdf/mupdfjs"