| FoxitPDFSDKforWeb v11.0.5 Archives Foxit PDF SDK for Web

Public Member Functions | List of all members
Widget Class Reference
PDF » annots

A class that represents a form widget in a PDF document. More...

Inheritance diagram for Widget:

## Public Member Functions
| getAdditionalAction ()
| Retrives the additional action object. More...
| getAlignment ()
| Retrieves the text alignment of a widget in a PDF form. More...
| getDefaultAppearance ()
| Retrieves the default appearance of the form widget. More...
| getDirectionRTL ()
| Retrieves the text direction of a widget in a PDF form. More...
| getExportValue ()
| Retrieves the export value of the form widget. The export value is typically used for checkboxes and radio buttons. More...
| getField ()
| Retrieves the `PDFFormField` object associated with the widget. More...
| getFont ()
| Retrieves the font of the form widget. More...
| getHighlightingMode ()
| Retrieves the highlighting mode of the widget Highlighting mode is the visual effect to be used when the mouse button is pressed or held down inside its active area. More...
| getIconCaptionRelation ()
| Retrieves the relation of the icon and caption of the form widget. More...
| getIconFitOptions ()
| Retrieves the icon fit options of the form widget. More...
| getMKBorderColor ()
| Retrieves the border color of the form widget. More...
| getMKCaptionOptions ()
| Retrieves the caption options of the form widget. More...
| getMKFillColor ()
| Retrieves the fill color of the form widget. More...
async | getMKIcon (state:WidgetGestureState)
| Retrieves the icon of the form widget in a given state. More...
| getMKIconOptions ()
| Retrieves the icon options of the form widget. More...
| getNormalCaption ()
| Retrieves the normal caption of the (push button/checkbox/radio button) widget. More...
| getPage ()
| Retrieves the PDF page associated with the widget. More...
| getRotation ()
| Retrieves the rotation of the form widget. More...
| getTextColor ()
| Retrieves the text color of the form widget. More...
| getTextSize ()
| Retrieves the text size of the form widget. More...
| getWidgetId ()
| Retrieves the unique identifier of the form widget. This method is an alias for the Annot.getAnnotId method. It provides the same unique identifier used for annotations. More...
async | removeMKIcon (state:WidgetGestureState)
| Removes the icon of the form widget in a given state. More...
async | setAlignment (alignment:TextWidgetAlignment)
| Sets the text alignment of a widget in a PDF form. More...
| setDefaultAppearance (appearance:Partial<{ textColor:number;textSize:number;fontName:string;}>)
| Sets the default appearance of the form widget. More...
async | setDirectionRTL (direction:FormWidgetDirection)
| Sets the text direction of a widget in a PDF form. More...
| setExportValue (value:string)
| Sets the export value of the form widget(checkbox/radio button). More...
| setFontName (fontName:string)
| Sets the font name of the form widget. More...
async | setHighlightingMode (mode:HighlightingMode)
| Sets the highlighting mode of the form widget. More...
async | setIconCaptionRelation (relation:WidgetIconCaptionRelation)
| Sets the relation of the icon and caption of the form widget. More...
| setIconFitOptions (options:MKIconFitOptions)
| Sets the options for fitting icons to the widget bounds. More...
| setMKBorderColor (color:number|undefined)
| Sets the border color of the form widget. More...
async | setMKCaption (state:WidgetGestureState, caption:string)
| Sets the caption of the form widget in a given state. More...
| setMKFillColor (color:number|undefined)
| Sets the fill color of the form widget. More...
async | setMKIcon (state:WidgetGestureState, buffer:ArrayBuffer)
| Sets the icon of the form widget in a given state. More...
| setNormalCaption (caption:string='')
| Sets the normal caption of the (push button/checkbox/radio button) widget. More...
async | setRotation (rotation:FormWidgetRotation)
| Sets the rotation of the form widget. More...
| setTextColor (textColor:number)
| Sets the text color of the form widget. More...
| setTextSize (textSize:number)
| Sets the text size of the form widget. More...
Public Member Functions inherited from Annot
| appendAction (actionSpec)
| Appends a action to the annotation. This function cannot be used to append action which is used as additional action. More...
| exportToJSON ()
| Export the current annotation to a Json object. [Support in Server] More...
| getActionData ()
| Retrieves the action associated with this annotation. This function cannot be used to get action which is used as additional action. More...
| getAllActionData ()
| Gets all action data associated with the annotation. This method retrieves all action data including both primary and additional actions of the annotation. The action will be grouped by action trigger type: ActionTriggerEvents.ANNOT_MOUSE_BUTTON_RELEASED. More...
| getAnnotId ()
| Retrieves the unique identifier of the annotation. The identifier consists of two components: the page index and the object number, which together ensure the annotation's uniqueness within the document. More...
| getBorderColor ()
| Get annotation's border color. [Support in Server] More...
| getBorderInfo ()
| Get annotation's border information. [Support in Server] More...
| getBorderStyle ()
| Get annotation's border style. More...
| getContent ()
| Get annotation's contents. [Support in Server] More...
| getDictionaryEntry (key)
| Get the dictionary property of Annot by key. More...
| getFlags ()
| Get annotation's flag. [Support in Server] More...
| getModifiedDateTime ()
| Get annotation's last modified date time. [Support in Server] More...
| getObjectNumber ()
| Get annotation's object number. More...
| getPage ()
| Get annotation's page. [Support in Server] More...
| getRect ()
| Get annotation's rect. [Support in Server] More...
| getTitle ()
| Get annotation's title. [Support in Server] More...
| getType ()
| Get annotation's type. [Support in Server] More...
| getUniqueID ()
| Get annotation's unique ID. [Support in Server] More...
| isEmpty ()
| Check annotation is empty or not. [Support in Server] More...
| isMarkup ()
| Check if current annotation is a markup annotation. [Support in Server] More...
| removeAction (actionObjNumber)
| Removes a action from the annotation. This function cannot be used to remove action which is used as additional action. More...
| setAction (actionSpec)
| Set the action for the annotation. This function cannot be used to set action which is used as additional action. More...
| setBorderColor (borderColor)
| Set annotation's border color. [Support in Server] More...
| setBorderInfo (borderInfo)
| Set annotation's border information. [Support in Server] More...
| setBorderStyle (borderStyle, styleParam)
| Set annotation's border style. More...
| setContent (content)
| Set contents for the currently gotten annotation. [Support in Server] More...
| setCustomAPStream (appearanceType, appearanceStream)
| setDictionaryEntry (key, value)
| Add a new entry or replace the existing entry of the annotation dictionary. Caller could use this method to store their private data to the annotation. Do not use any standard key of the annotation dictionary, such as 'Type', 'Subtype', 'Rect' defined in PDF Reference. If any standard key is used, this behaviour will be undefined. More...
| setFlags (flag, notTriggerEvent)
| Set annotation's flag. [Support in Server] More...
| setModifiedDateTime (date)
| Set annotation's last modified date time. [Support in Server] More...
| setRect (rect)
| Set annotation's rect. More...
| supportsAction ()
| This method checks the annotation type and returns true if the type is screen, link or sound annotation, Indicating that are supports actions. For other types of annotation, it returns false. More...
| updateAction (actionObjNumber, actionData)
| Updates an existing action in the annotation. This function cannot be used to update action which is used as additional action. More...
Public Member Functions inherited from Disposable
| addDestroyHook (...hooks)
| Add a function to destroyHooks list, which will be called during destroy. More...
| destroy ()
| ownsTo (owner)
| Establishes an ownership relationship where this instance will be destroyed when the owner is destroyed. Additionally, the owner will be automatically removed from the destroyHooks list when this instance is destroyed. More...

## Detailed Description

A class that represents a form widget in a PDF document.

Since
  11.0.0

## Member Function Documentation

## ◆ getAdditionalAction()

Widget::getAdditionalAction | ( |  | ) |
| inline

Retrives the additional action object.

Returns
  AdditionalAction<AnnotActionTriggerEvents|FieldActionTriggerEvents> - The additional action object used to manipulate additional actions.

Since
  11.0.0

## ◆ getAlignment()

Widget::getAlignment | ( |  | ) |
| inline

Retrieves the text alignment of a widget in a PDF form.

Returns
  Promise<TextWidgetAlignment> - A promise that resolves with the text alignment of the form widget. The value can be one of the following:
  - 0: Left alignment.
  - 1: Center alignment.
  - 2: Right alignment.

Since
  11.0.0

## ◆ getDefaultAppearance()

Widget::getDefaultAppearance | ( |  | ) |
| inline

Retrieves the default appearance of the form widget.

Returns
  Promise<DefaultAppearance> - A promise that resolves with the default appearance of the form widget.

Since
  11.0.0

## ◆ getDirectionRTL()

Widget::getDirectionRTL | ( |  | ) |
| inline

Retrieves the text direction of a widget in a PDF form.

Returns
  Promise<FormWidgetDirection> - A promise that resolves with the text direction of the form widget. The value can be one of the following:
  - 0: The text flows from left to right.
  - 1: The text flows from right to left.

Since
  11.0.0

## ◆ getExportValue()

Widget::getExportValue | ( |  | ) |
| inline

Retrieves the export value of the form widget. The export value is typically used for checkboxes and radio buttons.

Returns
  Promise<string> - A promise that resolves with the export value of the form widget.

Since
  11.0.0

## ◆ getField()

Widget::getField | ( |  | ) |
| inline

Retrieves the `PDFFormField` object associated with the widget.

Returns
  PDFFormField|undefined - The associated `PDFFormField` object, or `undefined` if the widget is not associated with any form field.

Since
  11.0.0

## ◆ getFont()

Widget::getFont | ( |  | ) |
| inline

Retrieves the font of the form widget.

Returns
  Promise<DefaultAppearanceFontInfo | undefined> - A promise that resolves with the font of the form widget, or undefined if not set.

Since
  11.0.0

See also
  getDefaultAppearance

## ◆ getHighlightingMode()

Widget::getHighlightingMode | ( |  | ) |
| inline

Retrieves the highlighting mode of the widget Highlighting mode is the visual effect to be used when the mouse button is pressed or held down inside its active area.

Returns
  Promise<HighlightingMode> -

Since
  11.0.0

## ◆ getIconCaptionRelation()

Widget::getIconCaptionRelation | ( |  | ) |
| inline

Retrieves the relation of the icon and caption of the form widget.

Returns
  Promise<WidgetIconCaptionRelation> - A promise that resolves with the relation of the icon and caption of the form widget.

Since
  11.0.0

## ◆ getIconFitOptions()

Widget::getIconFitOptions | ( |  | ) |
| inline

Retrieves the icon fit options of the form widget.

Returns
  Promise<MKIconFitOptions> - A promise that resolves with the icon fit options of the form widget.

Since
  11.0.0

## ◆ getMKBorderColor()

Widget::getMKBorderColor | ( |  | ) |
| inline

Retrieves the border color of the form widget.

Returns
  Promise<number | undefined> - A promise that resolves with the border color of the form widget. The color is represented as a 32-bit integer in the format 0xRRGGBB, or undefined if not set.

Since
  11.0.0

## ◆ getMKCaptionOptions()

Widget::getMKCaptionOptions | ( |  | ) |
| inline

Retrieves the caption options of the form widget.

Returns
  Promise<MKCaptionOptions> - A promise that resolves with the caption options of the form widget.

Since
  11.0.0

## ◆ getMKFillColor()

Widget::getMKFillColor | ( |  | ) |
| inline

Retrieves the fill color of the form widget.

Returns
  Promise<number | undefined> - A promise that resolves with the fill color of the form widget. The color is represented as a 32-bit integer in the format 0xRRGGBB, or undefined if not set.

Since
  11.0.0

## ◆ getMKIcon()

async Widget::getMKIcon | ( |  | state:WidgetGestureState | ) |
| inline

Retrieves the icon of the form widget in a given state.

Parameters

  state | WidgetGestureState - The state of the form widget for which the icon is retrieved.

Returns
  Promise<MKIconBitmap | undefined> - A promise that resolves with the icon of the form widget in the given state, or undefined if not set.

Exceptions

  Error | if the specified state is invalid.

Since
  11.0.0

## ◆ getMKIconOptions()

Widget::getMKIconOptions | ( |  | ) |
| inline

Retrieves the icon options of the form widget.

Returns
  Promise<MKIconOptions> - A promise that resolves with the icon options of the form widget.

Since
  11.0.0

## ◆ getNormalCaption()

Widget::getNormalCaption | ( |  | ) |
| inline

Retrieves the normal caption of the (push button/checkbox/radio button) widget.

Note
  If the widget is a radio button or checkbox, the caption should be one of the following:
  - 'l': Circle
  - '8': Cross
  - 'u': Diamond
  - 'n': Square
  - 'H': Star
  - '4': Check

Returns
  Promise<string> - A promise that resolves with the normal caption of the (push button/checkbox/radio button) widget.

Since
  11.0.0

## ◆ getPage()

Widget::getPage | ( |  | ) |
| inline

Retrieves the PDF page associated with the widget.

Returns
  PDFPage - The PDF page associated with the widget.

Since
  11.0.0

## ◆ getRotation()

Widget::getRotation | ( |  | ) |
| inline

Retrieves the rotation of the form widget.

Returns
  Promise<FormWidgetRotation> - A promise that resolves with the rotation of the form widget.

Since
  11.0.0

## ◆ getTextColor()

Widget::getTextColor | ( |  | ) |
| inline

Retrieves the text color of the form widget.

Returns
  Promise<number | undefined> - A promise that resolves with the text color of the form widget. The color is represented as a 24-bit integer in the format 0xRRGGBB, or undefined if not set.

Since
  11.0.0

See also
  setDefaultAppearance

## ◆ getTextSize()

Widget::getTextSize | ( |  | ) |
| inline

Retrieves the text size of the form widget.

Returns
  Promise<number | undefined> - A promise that resolves with the text size of the form widget. The text size is a positive number, or undefined if not set.

Since
  11.0.0

See also
  getDefaultAppearance

## ◆ getWidgetId()

Widget::getWidgetId | ( |  | ) |
| inline

Retrieves the unique identifier of the form widget. This method is an alias for the Annot.getAnnotId method. It provides the same unique identifier used for annotations.

Returns
  AnnotId - The unique identifier of the widget.

Since
  11.0.0

## ◆ removeMKIcon()

async Widget::removeMKIcon | ( |  | state:WidgetGestureState | ) |
| inline

Removes the icon of the form widget in a given state.

Parameters

  state | WidgetGestureState - The state of the form widget for which the icon is removed.

Returns
  Promise<void> - A promise that resolves when the icon of the form widget in the given state is removed.

Exceptions

  Error | if the specified state is invalid.

Since
  11.0.0

See also
  AnnotUpdatedType.formWidgetIconUpdated

## ◆ setAlignment()

async Widget::setAlignment | ( |  | alignment:TextWidgetAlignment | ) |
| inline

Sets the text alignment of a widget in a PDF form.

Parameters

  alignment | TextWidgetAlignment - The text alignment of the form widget. The value can be one of the following: 0: Left alignment. 1: Center alignment. 2: Right alignment.

Returns
  Promise<void> - A promise that resolves when the text alignment of the form widget is set.

Since
  11.0.0

See also
  AnnotUpdatedType.formWidgetAlignmentUpdated

## ◆ setDefaultAppearance()

Widget::setDefaultAppearance | ( |  | appearance:Partial<{ textColor:number;textSize:number;fontName:string;}> | ) |
| inline

Sets the default appearance of the form widget.

Parameters

  appearance | object - Json object of default appearance.
  [appearance.textColor] | number - Default appearance text color (0xRRGGBB).
  [appearance.textSize] | number - Default appearance text size. It should be a positive number.
  [appearance.fontName] | string - Default appearance font name.

Returns
  Promise<void> - A promise that resolves when the default appearance of the form widget is set.

Since
  11.0.0

See also
  AnnotUpdatedType.defaultAppearanceUpdated

## ◆ setDirectionRTL()

async Widget::setDirectionRTL | ( |  | direction:FormWidgetDirection | ) |
| inline

Sets the text direction of a widget in a PDF form.

Parameters

  direction | FormWidgetDirection - The text direction of the form widget. The value can be one of the following: 0: The text flows from left to right. 1: The text flows from right to left.

Returns
  Promise<void> - A promise that resolves when the text direction of the form widget is set.

Since
  11.0.0

See also
  AnnotUpdatedType.formWidgetDirectionRTLUpdated

## ◆ setExportValue()

Widget::setExportValue | ( |  | value:string | ) |
| inline

Sets the export value of the form widget(checkbox/radio button).

Parameters

  value | string - The export value of the form widget. It should not be an empty string.

Returns
  Promise<void> - A promise that resolves when the export value of the form widget is set.

Since
  11.0.0

See also
  AnnotUpdatedType.formWidgetExportValueUpdated

## ◆ setFontName()

Widget::setFontName | ( |  | fontName:string | ) |
| inline

Sets the font name of the form widget.

Parameters

  fontName | string - Font name to set.

Returns
  Promise<void> - A promise that resolves when the font name of the form widget is set.

Since
  11.0.0

See also
  setDefaultAppearance

## ◆ setHighlightingMode()

async Widget::setHighlightingMode | ( |  | mode:HighlightingMode | ) |
| inline

Sets the highlighting mode of the form widget.

Parameters

  mode | HighlightingMode - The highlighting mode of the form widget.

Returns
  Promise<void> - A promise that resolves when the highlighting mode of the form widget is set.

Exceptions

  Error | if the specified highlighting mode is invalid.

Since
  11.0.0

See also
  AnnotUpdatedType.formWidgetHighlightingModeUpdated

## ◆ setIconCaptionRelation()

async Widget::setIconCaptionRelation | ( |  | relation:WidgetIconCaptionRelation | ) |
| inline

Sets the relation of the icon and caption of the form widget.

Parameters

  relation | WidgetIconCaptionRelation - The relation of the icon and caption of the form widget.

Returns
  Promise<void> - A promise that resolves when the relation of the icon and caption of the form widget is set.

Since
  11.0.0

See also
  AnnotUpdatedType.formWidgetIconCaptionRelationUpdated
  AnnotUpdatedType.formWidgetIconUpdated
  AnnotUpdatedType.formWidgetCaptionUpdated

## ◆ setIconFitOptions()

Widget::setIconFitOptions | ( |  | options:MKIconFitOptions | ) |
| inline

Sets the options for fitting icons to the widget bounds.

Parameters

  options | MKIconFitOptions - The options for fitting icons to the widget bounds.

Returns
  Promise<void> - A promise that resolves when the options for fitting icons to the widget bounds are set.

Since
  11.0.0

See also
  AnnotUpdatedType.formWidgetIconFitUpdated

## ◆ setMKBorderColor()

Widget::setMKBorderColor | ( | color:number| | undefined | ) |
| inline

Sets the border color of the form widget.

Parameters

  color | number | undefined - The border color of the form widget. The color is represented as a 32-bit integer in the format 0xRRGGBB, or undefined to remove the border color.

Returns
  Promise<void> - A promise that resolves when the border color of the form widget is set.

Since
  11.0.0

See also
  AnnotUpdatedType.formWidgetMKBorderColorUpdated

## ◆ setMKCaption()

async Widget::setMKCaption | ( |  | state:WidgetGestureState,
|  |  | caption:string
| ) |  |
| inline

Sets the caption of the form widget in a given state.

Parameters

  state | WidgetGestureState - The state of the form widget for which the caption is set.
  caption | string - The caption of the form widget.

Returns
  Promise<void> - A promise that resolves when the caption of the form widget in the given state is set.

Exceptions

  Error | if the specified state is invalid.

Since
  11.0.0

See also
  AnnotUpdatedType.formWidgetCaptionUpdated

## ◆ setMKFillColor()

Widget::setMKFillColor | ( | color:number| | undefined | ) |
| inline

Sets the fill color of the form widget.

Parameters

  color | number | undefined - The fill color of the form widget. The color is represented as a 32-bit integer in the format 0xRRGGBB, or undefined to remove the fill color.

Returns
  Promise<void> - A promise that resolves when the fill color of the form widget is set.

Since
  11.0.0

See also
  AnnotUpdatedType.formWidgetMKFillColorUpdated

## ◆ setMKIcon()

async Widget::setMKIcon | ( |  | state:WidgetGestureState,
|  |  | buffer:ArrayBuffer
| ) |  |
| inline

Sets the icon of the form widget in a given state.

Parameters

  state | WidgetGestureState - The state of the form widget for which the icon is set.
  buffer | ArrayBuffer - The ArrayBuffer containing the icon data.

Returns
  Promise<void> - A promise that resolves when the icon of the form widget in the given state is set.

Exceptions

  Error | if the specified state is invalid.

Since
  11.0.0

See also
  AnnotUpdatedType.formWidgetIconUpdated

## ◆ setNormalCaption()

Widget::setNormalCaption | ( |  | caption:string = `''` | ) |
| inline

Sets the normal caption of the (push button/checkbox/radio button) widget.

Note
  If the widget is a radio button or checkbox, the caption should be one of the following:
  - 'l': Circle
  - '8': Cross
  - 'u': Diamond
  - 'n': Square
  - 'H': Star
  - '4': Check

Parameters

  caption | string - The normal caption of the (push button/checkbox/radio button) widget.

Returns
  Promise<void> - A promise that resolves when the normal caption of the (push button/checkbox/radio button) widget is set.

Since
  11.0.0

See also
  AnnotUpdatedType.formWidgetNormalCaptionUpdated

## ◆ setRotation()

async Widget::setRotation | ( |  | rotation:FormWidgetRotation | ) |
| inline

Sets the rotation of the form widget.

Parameters

  rotation | FormWidgetRotation - The rotation of the form widget. The value can be one of the following: 0: No rotation. 1: Rotate 90 degrees clockwise. 2: Rotate 180 degrees clockwise. 3: Rotate 90 degrees counter-clockwise.

Returns
  Promise<void> - A promise that resolves when the rotation of the form widget is set.

Since
  11.0.0

See also
  AnnotUpdatedType.formWidgetRotationUpdated

## ◆ setTextColor()

Widget::setTextColor | ( |  | textColor:number | ) |
| inline

Sets the text color of the form widget.

Parameters

  textColor | number - Text color to set, represented as a 24-bit integer in the format 0xRRGGBB.

Returns
  Promise<void> - A promise that resolves when the text color of the form widget is set.

Since
  11.0.0

See also
  setDefaultAppearance

## ◆ setTextSize()

Widget::setTextSize | ( |  | textSize:number | ) |
| inline

Sets the text size of the form widget.

Parameters

  textSize | number - Text size to set. It should be a positive number.

Returns
  Promise<void> - A promise that resolves when the text size of the form widget is set.

Since
  11.0.0

See also
  setDefaultAppearance

@2025 Foxit Software Incorporated. All rights reserved.