| FoxitPDFSDKforWeb v11.0.6 Archives Foxit PDF SDK for Web

Public Member Functions | Public Attributes | List of all members
PDFFormProperty< T > Class Reference
UIExtension » addons » form_designer_addon

Represents the properties of a PDF form field, encapsulating details about its availability, visibility, value presence, and the actual value. More...

## Public Member Functions
Function | onchange (callback)
| Register a callback function that is called when the form property changes. More...

## Public Attributes
boolean | available
| Indicates whether the form property is available for interaction. May be false when multiple form widgets are activated. More...
boolean | hasValue
| Indicates whether the form property currently holds a value. May be false when multiple form widgets are activated and their values are not the same.
T | value
| The value of the form property. When hasValue is false, the value must be undefined.
boolean | visible
| Indicates whether the form property is visible to the user. May be false when multiple form widgets are activated. More...

## Detailed Description

Represents the properties of a PDF form field, encapsulating details about its availability, visibility, value presence, and the actual value.

Example （examples/UIExtension/form/custom-form-properties-editor）:

class CustomWidgetBorderColorEditorComponent extends UIExtension.SeniorComponentFactory.createSuperClass({
template: `<color-picker-button
@on.change="$component.onUserChangedColor($args[0])"
@form-designer-v2:form-property="$component.property"
></color-picker-button>`
}) {
static getName() {
return 'custom-widget-border-color-editor'
}
async mounted() {
super.mounted();
const addon = await this.getPDFUI().getAddonInstance('FormDesigner');
const propertiesService = addon.getPDFFormPropertiesService();
this.property = propertiesService.getWidgetBorderColor();
this.property.ownsTo(this);
this.onPropertyChange(this.property);
this.property.onChange(() => {
this.onPropertyChange(this.property);
this.digest();
})
}
async onUserChangedColor(color) {
const addon = await this.getPDFUI().getAddonInstance('FormDesigner');
const propertiesService = addon.getPDFFormPropertiesService();
const widgets = await propertiesService.getSelectedWidgets()
await widgets.reduce(async (lastPromise, widget) => {
await lastPromise;
if(color === 0) {
return widget.setMKBorderColor(undefined);
} else {
const colorNum = parseInt(color.replace('#', ''), 16);
return widget.setMKBorderColor(colorNum);
}
}, Promise.resolve())
}
onPropertyChange(property) {
if(!property.hasValue || property.value === undefined) {
this.setValue(undefined);
} else {
const value = '#' + property.value.toString(16).padStart(6, '0');
this.setValue(value);
}
}
}
UIExtension.modular.module('custom', []).registerComponent(WidgetBorderColorEditorComponent);
// Use this component in the form widget properties panel
<custom:custom-widget-border-color-editor></custom:custom-widget-border-color-editor>

Since
  11.0.0

See also
  FormDesignerAddon.getPDFFormPropertiesService
  PDFFormPropertiesService

## Member Function Documentation

## ◆ onchange()

Function PDFFormProperty< T >::onchange | ( | callback |  | ) |

Register a callback function that is called when the form property changes.

Parameters

  callback | (hasValue:boolean,value:T|undefined)=>void - The callback function that is called when the form property changes.

Returns
  Function - The function that unsubscribes the callback.

Since
  11.0.0

## Member Data Documentation

## ◆ available

boolean PDFFormProperty< T >::available

Indicates whether the form property is available for interaction. May be false when multiple form widgets are activated.

Since
  11.0.0

## ◆ visible

boolean PDFFormProperty< T >::visible

Indicates whether the form property is visible to the user. May be false when multiple form widgets are activated.

Since
  11.0.0

@2025 Foxit Software Incorporated. All rights reserved.