import { ObjectBase } from "../../ObjectBase"; import { WidgetAnnotation } from "../Annotations/WidgetAnnotation"; import { PdfCollection } from "../PdfCollection"; import type { VariableTextJustification } from "../../Enums"; import type { FieldCollection } from "./FieldCollection"; import type { PdfDocument } from "../PdfDocument"; import type { PdfPage } from "../PdfPage"; import type { CheckBoxFieldProperties } from "./CheckBoxField"; import type { ComboBoxFieldProperties } from "./ComboBoxField"; import type { ListBoxFieldProperties } from "./ListBoxField"; import type { TextFieldProperties } from "./TextField"; import type { CombTextFieldProperties } from "./CombTextField"; import type { PushButtonFieldProperties } from "./PushButtonField"; import type { RadioButtonFieldProperties } from "./RadioButtonField"; import type { SignatureFieldProperties } from "./SignatureField"; import type { WidgetProperties } from "../Annotations/WidgetAnnotation"; import { ActionJavaScript, type ActionJavaScriptProperties } from "../Action"; /** * Defines common properties for all acroform fields. * @see {@link Field} */ export type FieldBaseProperties = { /** * The justification to be used in displaying the field's text. * Note that this field is used only if {@link WidgetAnnotation#justification} is not specified. */ justification?: VariableTextJustification; /** * The field's name. */ name?: string; /** * An alternate field name to be used in place of the actual field name wherever * the field must be identified in the user interface (such as in error or status messages referring to the field). * This text is also useful when extracting the document's contents in support of accessibility * to users with disabilities or for other purposes. */ alternateName?: string; /** * The mapping name to be used when exporting interactive form field data from the document. */ mappingName?: string; /** * The field's value. */ value?: number | string | boolean | number[] | null; /** * The field's default value. */ defaultValue?: number | string | boolean | number[] | null; /** * Indicating whether the user may not change the value of the field. * Any associated widget annotations will not interact with the user; that is, * they will not respond to mouse clicks or change their appearance in response to mouse motions. * This flag is useful for fields whose values are computed or imported from a database. */ readOnly?: boolean; /** * Indicating whether the field must have a value at the time it is * exported by a {@link ActionSubmitForm} action. */ required?: boolean; /** * Indicating whether the field must not be exported by a {@link ActionSubmitForm} action. */ export?: boolean; /** * An index that is used to determine the field's calculation order. * Fields with lower indices are calculated before fields with higher indices. * * If several fields have the same CalculationIndex, the calculation order is determined * by the order of fields in the collection. */ calculationIndex?: number; /** * The default page where field appears. * Note, this value is used if it is not specified using 'widget' property. */ page?: PdfPage; }; /** * The type combining all field properties types. */ export type FieldProperties = CheckBoxFieldProperties | ComboBoxFieldProperties | CombTextFieldProperties | ListBoxFieldProperties | TextFieldProperties | PushButtonFieldProperties | RadioButtonFieldProperties | SignatureFieldProperties; /** * Represents a collection of {@link Field} objects. **/ export declare class FieldWidgetCollection extends PdfCollection { get count(): number; getAt(index: number): WidgetAnnotation; setAt(index: number, item: WidgetAnnotation): void; insert(index: number, item: WidgetAnnotation | WidgetProperties): void; contains(item: WidgetAnnotation): boolean; remove(item: WidgetAnnotation): boolean; removeAt(index: number): void; clear(): void; add(item: WidgetAnnotation | WidgetProperties): void; /** * Gets the {@link Field} object that owns this collection. */ get owner(): Field; } /** * Defines AcroForm field. */ export declare class Field extends ObjectBase { /** * Gets or sets the justification to be used in displaying the field's text. * Note that this field is used only if {@link WidgetAnnotation#justification} is not specified. */ get justification(): VariableTextJustification | null; /** * Gets or sets the justification to be used in displaying the field's text. * Note that this field is used only if {@link WidgetAnnotation#justification} is not specified. */ set justification(value: VariableTextJustification | null); /** * Gets the list of child fields. */ get children(): FieldCollection; /** * Gets the parent field. */ get parent(): Field | null; /** * Gets the {@link PdfDocument} owning this field. */ get doc(): PdfDocument | null; /** * Gets the {@link FieldCollection} containing this field. */ get owner(): FieldCollection | null; /** * Gets the list of widget annotations associated with this field. */ get widgets(): FieldWidgetCollection; /** * Gets or sets the field's name. */ get name(): string | null; /** * Gets or sets the field's name. */ set name(value: string); /** * Gets or sets an alternate field name to be used in place of the actual field name wherever * the field must be identified in the user interface (such as in error or status messages referring to the field). * This text is also useful when extracting the document's contents in support of accessibility * to users with disabilities or for other purposes. */ get alternateName(): string | null; /** * Gets or sets an alternate field name to be used in place of the actual field name wherever * the field must be identified in the user interface (such as in error or status messages referring to the field). * This text is also useful when extracting the document's contents in support of accessibility * to users with disabilities or for other purposes. */ set alternateName(value: string | null); /** * Gets or sets the mapping name to be used when exporting interactive form field data from the document. */ get mappingName(): string | null; /** * Gets or sets the mapping name to be used when exporting interactive form field data from the document. */ set mappingName(value: string | null); /** * Gets or sets the field's value. */ get value(): number | string | boolean | number[] | null; /** * Gets or sets the field's value. */ set value(value: number | string | boolean | number[] | null); /** * Gets or sets the field's default value. */ get defaultValue(): number | string | boolean | number[] | null; /** * Gets or sets the field's default value. */ set defaultValue(value: number | string | boolean | number[] | null); /** * Gets or sets a value indicating whether the user may not change the value of the field. * Any associated widget annotations will not interact with the user; that is, * they will not respond to mouse clicks or change their appearance in response to mouse motions. * This flag is useful for fields whose values are computed or imported from a database. */ get readOnly(): boolean; /** * Gets or sets a value indicating whether the user may not change the value of the field. * Any associated widget annotations will not interact with the user; that is, * they will not respond to mouse clicks or change their appearance in response to mouse motions. * This flag is useful for fields whose values are computed or imported from a database. */ set readOnly(value: boolean); /** * Gets or sets a value indicating whether the field must have a value at the time it is * exported by a {@link ActionSubmitForm} action. */ get required(): boolean; /** * Gets or sets a value indicating whether the field must have a value at the time it is * exported by a {@link ActionSubmitForm} action. */ set required(value: boolean); /** * Gets or sets a value indicating whether the field must not be exported by a {@link ActionSubmitForm} action. */ get export(): boolean; /** * Gets or sets a value indicating whether the field must not be exported by a {@link ActionSubmitForm} action. */ set export(value: boolean); /** * Gets or sets an index that is used to determine the field's calculation order. * Fields with lower indices are calculated before fields with higher indices. * * If several fields have the same CalculationIndex, the calculation order is determined * by the order of fields in the collection. * * {@link recalculateValue} can be used to specify JavaScript that is used to calculate the field's value. */ get calculationIndex(): number; /** * Gets or sets an index that is used to determine the field's calculation order. * Fields with lower indices are calculated before fields with higher indices. * * If several fields have the same CalculationIndex, the calculation order is determined * by the order of fields in the collection. * * {@link recalculateValue} can be used to specify JavaScript that is used to calculate the field's value. */ set calculationIndex(value: number); /** * Gets or sets a JavaScript action to be performed when the user types a keystroke into a * text field or combo box or modifies the selection in a scrollable list box. * This action can check the keystroke for validity and reject or modify it. */ get keyPress(): ActionJavaScript | null; /** * Gets or sets a JavaScript action to be performed when the user types a keystroke into a * text field or combo box or modifies the selection in a scrollable list box. * This action can check the keystroke for validity and reject or modify it. */ set keyPress(value: ActionJavaScript | ActionJavaScriptProperties | null); /** * Gets or sets a JavaScript action to be performed before the field is formatted to display its current value. * This action can modify the field's value before formatting. */ get formatValue(): ActionJavaScript | null; /** * Gets or sets a JavaScript action to be performed before the field is formatted to display its current value. * This action can modify the field's value before formatting. */ set formatValue(value: ActionJavaScript | ActionJavaScriptProperties | null); /** * Gets or sets a JavaScript action to be performed when the field's value is changed. * This action can check the new value for validity. */ get valueChanged(): ActionJavaScript | null; /** * Gets or sets a JavaScript action to be performed when the field's value is changed. * This action can check the new value for validity. */ set valueChanged(value: ActionJavaScript | ActionJavaScriptProperties | null); /** * Gets or sets a JavaScript action to be performed to recalculate the value of this field when * that of another field changes. */ get recalculateValue(): ActionJavaScript | null; /** * Gets or sets a JavaScript action to be performed to recalculate the value of this field when * that of another field changes. */ set recalculateValue(value: ActionJavaScript | ActionJavaScriptProperties | null); }