| FoxitPDFSDKforWeb v11.0.5 Archives Foxit PDF SDK for Web

Public Member Functions | List of all members
FormFillerService Class Reference
PDFViewCtrl » form

Service for handling PDF form filling operations. More...

Inheritance diagram for FormFillerService:

## Public Member Functions
| appendInteractionEventInterceptor (interceptor:FormInteractionEventInterceptor)
| Append a FormInteractionEventInterceptor to the end of the existing list. More...
| getDesignMode ()
| Get the current form design mode. More...
| getHighlightColor ()
| Get the highlight color for form fields. More...
| getMouseOverControl ()
| Determines if there is currently a focused form widget control. More...
| isHighlightFormFields ()
| Check if form fields are highlighted. More...
| isInteractionEventEnabled ()
| Check if the interaction event is enabled. More...
| onClickWidget (callback:(widgetId:AnnotId, event:FormMouseEvent)=> void)
| Registers a callback function for form widget click events. More...
| onDataChanged (callback:(doc:PDFDoc, widgetId:AnnotId)=> void)
| Registers a callback function that is called when data changes occur in a form widget. More...
| onDesignModeChange (callback:(designMode:FormDesignMode)=> void)
| Subscribe to design mode change events. More...
| onFocusChange (callback:(current?:AnnotId, origin?:AnnotId)=> void)
| Callback when the focus is changed. More...
| onKeyDown (callback:(widgetId:AnnotId|undefined, event:FormKeyboardEvent)=>void)
| Registers a callback function for key down events. More...
| onKeyUp (callback:(widgetId:AnnotId|undefined, event:FormKeyboardEvent)=>void)
| Registers a callback function for key up events. More...
| onMouseDownWidget (callback:(widgetId:AnnotId, event:FormMouseEvent)=> void)
| Registers a callback function for form widget mouse down events. More...
| onMouseLeaveWidget (callback:(widgetId:AnnotId)=> void)
| Registers a callback function for form widget mouse leave events. More...
| onMouseOverWidget (callback:(widgetId:AnnotId)=> void)
| Registers a callback function for form widget mouse over events. More...
| onMouseUpWidget (callback:(widgetId:AnnotId, event:FormMouseEvent)=> void)
| Registers a callback function for form widget mouse up events. More...
| onRightClickWidget (callback:(widgetId:AnnotId, event:FormMouseEvent)=> void)
| Registers a callback function for form widget right click events. More...
| removeFocus ()
| Removes focus from the currently focused form widget control. More...
async | setDesignMode (designMode:FormDesignMode)
| Set the current form design mode. More...
async | setFocus (annotId:AnnotId)
| Sets the focus on the specified form widget control. More...
| setHighlightColor (color:number)
| Set the highlight color for form fields. More...
async | setHighlightFields (isHighlight:boolean)
| Set the highlight state of form fields in the document and redraw the page immediately. More...
| toggleInteractionEvent (enabled:boolean)
| Toggle the form interaction event on or off, and when the interaction event is turned off, it will not be possible to interact with the form widget. 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

Service for handling PDF form filling operations.

This service provides multiple methods to interact with and manipulate form widgets within a PDF document, including creation, event handling, and design mode management.

Since
  11.0.0

See also
  PDFViewer.getFormFillerService

## Member Function Documentation

## ◆ appendInteractionEventInterceptor()

FormFillerService::appendInteractionEventInterceptor | ( |  | interceptor:FormInteractionEventInterceptor | ) |
| inline

Append a FormInteractionEventInterceptor to the end of the existing list.

The interceptor is called after the existing interceptors and before the default behavior of the form widget. The interceptor can call the next interceptor by calling the next function, or settle the event by not calling the next function.

Parameters

  interceptor | FormInteractionEventInterceptor - The interceptor to append.

Returns
  ()=>void - A function which can be called to remove the interceptor.

Since
  11.0.0

## ◆ getDesignMode()

FormFillerService::getDesignMode | ( |  | ) |
| inline

Get the current form design mode.

Returns
  FormDesignMode - The current form design mode.

Since
  11.0.0

## ◆ getHighlightColor()

FormFillerService::getHighlightColor | ( |  | ) |
| inline

Get the highlight color for form fields.

This method returns a promise that resolves to the current highlight color for form fields in the current PDF document as a 24-bit hex color code.

Returns
  Promise<number> - A promise that resolves to the current highlight color.

## ◆ getMouseOverControl()

FormFillerService::getMouseOverControl | ( |  | ) |
| inline

Determines if there is currently a focused form widget control.

Returns the currently mouse-overed form widget control.

Returns
  AnnotId|undefined - The mouse-overed control, or undefined if there is no mouse-overed control.

Since
  11.0.0

Returns
  boolean - Returns true if there is a focused control, otherwise false.

Since
  11.0.0

## ◆ isHighlightFormFields()

FormFillerService::isHighlightFormFields | ( |  | ) |
| inline

Check if form fields are highlighted.

This method returns a promise that resolves to a boolean indicating whether the form fields in the current PDF document are highlighted.

Returns
  Promise<boolean> - A promise that resolves to true if form fields are highlighted, otherwise false.

## ◆ isInteractionEventEnabled()

FormFillerService::isInteractionEventEnabled | ( |  | ) |
| inline

Check if the interaction event is enabled.

This method returns a boolean value indicating whether the interaction event is enabled.

Returns
  boolean - Whether the interaction event is enabled.

Since
  11.0.0

## ◆ onClickWidget()

FormFillerService::onClickWidget | ( |  | callback:(widgetId:AnnotId, event:FormMouseEvent),
|  |  | void
| ) |  |
| inline

Registers a callback function for form widget click events.

Parameters

  callback | (widgetId:AnnotId,event:FormMouseEvent)=>void - The callback function, which will be called when a click event occurs on a form widget. The callback function will receive the widget id and FormMouseEvent as arguments.

Returns
  ()=>void - A function that can be used to cancel the registration and remove the callback function.

Note
  To intercept the event, consider utilizing the `appendInteractionEventInterceptor` method, which provides a mechanism for pre-processing or modifying event behavior before it reaches the callback.

Since
  11.0.0

## ◆ onDataChanged()

FormFillerService::onDataChanged | ( |  | callback:(doc:PDFDoc, widgetId:AnnotId),
|  |  | void
| ) |  |
| inline

Registers a callback function that is called when data changes occur in a form widget.

The callback is triggered after the user inputs characters or changes the selection in ListBox, ComboBox, or DateTime Field widgets.

Parameters

  callback | (doc:PDFDoc,widgetId: AnnotId)=>void - The callback function to be registered, which receives the PDF document and the widget id as arguments.

Returns
  ()=>void - A function to unregister the callback.

## ◆ onDesignModeChange()

FormFillerService::onDesignModeChange | ( |  | callback:(designMode:FormDesignMode),
|  |  | void
| ) |  |
| inline

Subscribe to design mode change events.

Parameters

  callback | (designMode: FormDesignMode)=>void - A callback which accepts one argument, `designMode`, which is the current design mode.

Returns
  ()=>void - A function to unsubscribe from the event.

Since
  11.0.0

## ◆ onFocusChange()

FormFillerService::onFocusChange | ( |  | callback:( current?:AnnotId, origin?:AnnotId),
|  |  | void
| ) |  |
| inline

Callback when the focus is changed.

Parameters

  callback | (current?:AnnotId,origin?:AnnotId)=>void - A callback with two arguments, `current` and `origin`. `current` is the current focused annot, and `origin` is the previous focused annot. When the focus is removed, `current` is undefined, and `origin` is the last focused annot.

Returns
  ()=>void - A function to remove the callback.

Since
  11.0.0

## ◆ onKeyDown()

FormFillerService::onKeyDown | ( |  | callback:(widgetId:AnnotId|undefined, event:FormKeyboardEvent),
|  |  | void
| ) |  |
| inline

Registers a callback function for key down events.

Parameters

  callback | (widgetId:AnnotId|undefined,event:FormKeyboardEvent)=>void - The callback function that will be triggered when a key down event occurs. The function receives the widget id (if exists) and the FormKeyboardEvent as arguments.

Returns
  ()=>void - A function to unregister the callback.

Since
  11.0.0

## ◆ onKeyUp()

FormFillerService::onKeyUp | ( |  | callback:(widgetId:AnnotId|undefined, event:FormKeyboardEvent),
|  |  | void
| ) |  |
| inline

Registers a callback function for key up events.

Parameters

  callback | (widgetId:AnnotId|undefined,event:FormKeyboardEvent)=>void - The callback function that will be triggered when a key up event occurs. The function receives the widget id (if exists) and the FormKeyboardEvent as arguments.

Returns
  ()=>void - A function to unregister the callback.

Since
  11.0.0

## ◆ onMouseDownWidget()

FormFillerService::onMouseDownWidget | ( |  | callback:(widgetId:AnnotId, event:FormMouseEvent),
|  |  | void
| ) |  |
| inline

Registers a callback function for form widget mouse down events.

Parameters

  callback | (widgetId:AnnotId,event:FormMouseEvent)=>void - The callback function, which will be called when a mouse down event occurs on a form widget. The callback function will receive the widget id and form mouse event as arguments.

Returns
  ()=>void - A function that can be used to cancel the registration and remove the callback function.

Note
  To intercept the event, consider utilizing the `appendInteractionEventInterceptor` method, which provides a mechanism for pre-processing or modifying event behavior before it reaches the callback.

Since
  11.0.0

## ◆ onMouseLeaveWidget()

FormFillerService::onMouseLeaveWidget | ( |  | callback:(widgetId:AnnotId),
|  |  | void
| ) |  |
| inline

Registers a callback function for form widget mouse leave events.

Parameters

  callback | (widgetId:AnnotId)=>void - The callback function, which will be called when a mouse leave event occurs on a form widget. The callback function will receive the widget id as an argument.

Returns
  ()=>void - A function that can be used to cancel the registration and remove the callback function.

Note
  To intercept the event, consider utilizing the `appendInteractionEventInterceptor` method, which provides a mechanism for pre-processing or modifying event behavior before it reaches the callback.

Since
  11.0.0

## ◆ onMouseOverWidget()

FormFillerService::onMouseOverWidget | ( |  | callback:(widgetId:AnnotId),
|  |  | void
| ) |  |
| inline

Registers a callback function for form widget mouse over events.

Parameters

  callback | (widgetId:AnnotId)=>void - The callback function, which will be called when a mouse over event occurs on a form widget. The callback function will receive the widget id as an argument.

Returns
  ()=>void -A function that can be used to cancel the registration and remove the callback function.

Note
  To intercept the event, consider utilizing the `appendInteractionEventInterceptor` method, which provides a mechanism for pre-processing or modifying event behavior before it reaches the callback.

Since
  11.0.0

## ◆ onMouseUpWidget()

FormFillerService::onMouseUpWidget | ( |  | callback:(widgetId:AnnotId, event:FormMouseEvent),
|  |  | void
| ) |  |
| inline

Registers a callback function for form widget mouse up events.

Parameters

  callback | (widgetId:AnnotId,event:FormMouseEvent)=>void - The callback function, which will be called when a mouse up event occurs on a form widget. The callback function will receive the widget id and form mouse event as arguments.

Returns
  ()=>void - A function that can be used to cancel the registration and remove the callback function.

Note
  To intercept the event, consider utilizing the `appendInteractionEventInterceptor` method, which provides a mechanism for pre-processing or modifying event behavior before it reaches the callback.

Since
  11.0.0

## ◆ onRightClickWidget()

FormFillerService::onRightClickWidget | ( |  | callback:(widgetId:AnnotId, event:FormMouseEvent),
|  |  | void
| ) |  |
| inline

Registers a callback function for form widget right click events.

Parameters

  callback | (widgetId:AnnotId,event:FormMouseEvent)=>void - The callback function, which will be called when a right click event occurs on a form widget. The callback function will receive the widget id and FormMouseEvent as arguments.

Returns
  ()=>void - A function that can be used to cancel the registration and remove the callback function.

Note
  To intercept the event, consider utilizing the `appendInteractionEventInterceptor` method, which provides a mechanism for pre-processing or modifying event behavior before it reaches the callback.

Since
  11.0.0

## ◆ removeFocus()

FormFillerService::removeFocus | ( |  | ) |
| inline

Removes focus from the currently focused form widget control.

This method returns a promise that resolves once the focus has been removed. It also ensures that any necessary cleanup is performed by triggering the WidgetAnnot.handleOnLostFocus method if there was a widget control that was previously focused.

Returns
  Promise<void> - A promise that resolves when the focus is removed.

See also
  onFocusChange
  WidgetAnnot.handleOnLostFocus

Since
  11.0.0

## ◆ setDesignMode()

async FormFillerService::setDesignMode | ( |  | designMode:FormDesignMode | ) |
| inline

Set the current form design mode.

Parameters

  designMode | FormDesignMode - The form design mode to be set.

Returns
  Promise<void> - A promise which resolves when the design mode is set.

Since
  11.0.0

## ◆ setFocus()

async FormFillerService::setFocus | ( |  | annotId:AnnotId | ) |
| inline

Sets the focus on the specified form widget control.

Parameters

  annotId | AnnotId - The form widget control to set the focus on. The annotId should be an object with the properties "pageIndex" and "objNumber".

Exceptions

  Error | - Document not opening!
  Error | - Widget not found: page index <pageIndex>, widget id: <widgetId>
  Error | - Control not exist: page index <pageIndex>, widget id: <widgetId>

Returns
  Promise<void> - A promise that resolves when the focus is set, or rejects if an error occurs.

Since
  11.0.0

## ◆ setHighlightColor()

FormFillerService::setHighlightColor | ( |  | color:number | ) |
| inline

Set the highlight color for form fields.

This method sets the color used to highlight form fields when highlighting is enabled.

Parameters

  color | number - The color to set for form field highlighting. A number representing the 24-bit hex color code (0xRRGGBB).

Since
  11.0.0

## ◆ setHighlightFields()

async FormFillerService::setHighlightFields | ( |  | isHighlight:boolean | ) |
| inline

Set the highlight state of form fields in the document and redraw the page immediately.

This method toggles the highlighting of form fields within the current PDF document. When highlighting is enabled, the form fields are visually emphasized.

Since
  11.0.0

## ◆ toggleInteractionEvent()

FormFillerService::toggleInteractionEvent | ( |  | enabled:boolean | ) |
| inline

Toggle the form interaction event on or off, and when the interaction event is turned off, it will not be possible to interact with the form widget.

Parameters

  enabled | boolean - Whether to enable the interaction event.

Returns
  void

Since
  11.0.0

@2025 Foxit Software Incorporated. All rights reserved.