Skip to content

modern-pdf-lib


modern-pdf-lib / PdfDropdownField

Class: PdfDropdownField

Defined in: src/form/fields/dropdownField.ts:31

A PDF dropdown (combo box) field (/FT /Ch with Combo flag).

Options are stored in the /Opt array. The selected value is in /V. Optionally editable (bit 18 of /Ff).

Extends

Constructors

Constructor

new PdfDropdownField(name, dict, widgetDict, parentNames?): PdfDropdownField

Defined in: src/form/pdfField.ts:175

Parameters

name

string

dict

PdfDict

widgetDict

PdfDict

parentNames?

string[] = []

Returns

PdfDropdownField

Inherited from

PdfField.constructor

Properties

dict

protected readonly dict: PdfDict

Defined in: src/form/pdfField.ts:164

The underlying field dictionary (may contain both field and widget entries for simple one-widget fields).

Inherited from

PdfField.dict


fieldType

readonly fieldType: FieldType = 'dropdown'

Defined in: src/form/fields/dropdownField.ts:32

Discriminator for the concrete field type.

Overrides

PdfField.fieldType


name

readonly name: string

Defined in: src/form/pdfField.ts:158

The fully-qualified field name.

Inherited from

PdfField.name


parentNames

protected readonly parentNames: string[]

Defined in: src/form/pdfField.ts:173

Parent field dictionary chain for building full names.

Inherited from

PdfField.parentNames


widgetDict

protected readonly widgetDict: PdfDict

Defined in: src/form/pdfField.ts:170

The widget annotation dictionary. For merged field+widget dicts, this is the same object as dict.

Inherited from

PdfField.widgetDict

Methods

addToPage()

addToPage(page): void

Defined in: src/form/pdfField.ts:309

Add this field's widget annotation to a page.

Ensures the widget dict has /Type /Annot and /Subtype /Widget, then adds it to the page's annotation list so it appears in the rendered PDF.

Parameters

page

WidgetAnnotationHost

A page that implements WidgetAnnotationHost.

Returns

void

Inherited from

PdfField.addToPage


disableExporting()

disableExporting(): void

Defined in: src/form/pdfField.ts:271

Disable exporting this field (set the NoExport flag).

Returns

void

Inherited from

PdfField.disableExporting


enableExporting()

enableExporting(): void

Defined in: src/form/pdfField.ts:266

Enable exporting this field (clear the NoExport flag).

Returns

void

Inherited from

PdfField.enableExporting


generateAppearance()

generateAppearance(): PdfStream

Defined in: src/form/fields/dropdownField.ts:119

Generate the appearance stream for this dropdown.

Returns

PdfStream

Overrides

PdfField.generateAppearance


getFieldFlags()

protected getFieldFlags(): number

Defined in: src/form/pdfField.ts:211

Get the raw /Ff (field flags) integer value.

Returns

number

Inherited from

PdfField.getFieldFlags


getFullName()

getFullName(): string

Defined in: src/form/pdfField.ts:201

Get the fully qualified field name (Parent.Child.Name format). Per PDF spec SS12.7.3.2, the full name is formed by concatenating ancestor /T values with periods.

Returns

string

Inherited from

PdfField.getFullName


getName()

getName(): string

Defined in: src/form/pdfField.ts:192

Get the partial field name (/T entry).

Returns

string

Inherited from

PdfField.getName


getOptions()

getOptions(): string[]

Defined in: src/form/fields/dropdownField.ts:70

Get the list of options.

/Opt may be an array of strings, or an array of two-element arrays where element [0] is the export value and element [1] is the display value. We return the display values (or export values if no display).

Returns

string[]


getRect()

getRect(): [number, number, number, number]

Defined in: src/form/pdfField.ts:283

Get the field's widget rectangle as [x1, y1, x2, y2]. The /Rect entry comes from the widget annotation dictionary.

Returns

[number, number, number, number]

Inherited from

PdfField.getRect


getSelected()

getSelected(): string

Defined in: src/form/fields/dropdownField.ts:39

Get the currently selected value.

Returns

string


getValue()

getValue(): string

Defined in: src/form/fields/dropdownField.ts:50

Alias for getSelected().

Returns

string

Overrides

PdfField.getValue


hasFlag()

protected hasFlag(flag): boolean

Defined in: src/form/pdfField.ts:221

Check if a specific flag bit is set.

Parameters

flag

number

Returns

boolean

Inherited from

PdfField.hasFlag


isEditable()

isEditable(): boolean

Defined in: src/form/fields/dropdownField.ts:105

Whether the dropdown allows manual text entry.

Returns

boolean


isExported()

isExported(): boolean

Defined in: src/form/pdfField.ts:261

Whether the field is exported (inverse of NoExport flag).

Returns

boolean

Inherited from

PdfField.isExported


isNoExport()

isNoExport(): boolean

Defined in: src/form/pdfField.ts:256

Whether the field should not be exported.

Returns

boolean

Inherited from

PdfField.isNoExport


isReadOnly()

isReadOnly(): boolean

Defined in: src/form/pdfField.ts:236

Whether the field is read-only.

Returns

boolean

Inherited from

PdfField.isReadOnly


isRequired()

isRequired(): boolean

Defined in: src/form/pdfField.ts:246

Whether the field is required.

Returns

boolean

Inherited from

PdfField.isRequired


select()

select(value): void

Defined in: src/form/fields/dropdownField.ts:44

Select a value from the options.

Parameters

value

string

Returns

void


setEditable()

setEditable(editable): void

Defined in: src/form/fields/dropdownField.ts:110

Set whether the dropdown allows manual text entry.

Parameters

editable

boolean

Returns

void


setFieldFlags()

protected setFieldFlags(flags): void

Defined in: src/form/pdfField.ts:216

Set the raw /Ff (field flags) integer value.

Parameters

flags

number

Returns

void

Inherited from

PdfField.setFieldFlags


setFlag()

protected setFlag(flag, on): void

Defined in: src/form/pdfField.ts:226

Set or clear a specific flag bit.

Parameters

flag

number

on

boolean

Returns

void

Inherited from

PdfField.setFlag


setOptions()

setOptions(options): void

Defined in: src/form/fields/dropdownField.ts:94

Set the list of options.

Parameters

options

string[]

Returns

void


setReadOnly()

setReadOnly(readOnly): void

Defined in: src/form/pdfField.ts:241

Set the read-only flag.

Parameters

readOnly

boolean

Returns

void

Inherited from

PdfField.setReadOnly


setRequired()

setRequired(required): void

Defined in: src/form/pdfField.ts:251

Set the required flag.

Parameters

required

boolean

Returns

void

Inherited from

PdfField.setRequired


setValue()

setValue(value): void

Defined in: src/form/fields/dropdownField.ts:55

Alias for select().

Parameters

value

string | boolean | string[]

Returns

void

Overrides

PdfField.setValue

Released under the MIT License.