modern-pdf-lib / PdfRadioGroup
Class: PdfRadioGroup
Defined in: src/form/fields/radioGroup.ts:34
A PDF radio button group (/FT /Btn with Radio flag).
Multiple widget annotations represent the individual options. The field's /V value is the name of the selected option.
Extends
Constructors
Constructor
new PdfRadioGroup(
name,dict,widgetDict,parentNames?,widgets?):PdfRadioGroup
Defined in: src/form/fields/radioGroup.ts:40
Parameters
name
string
dict
widgetDict
parentNames?
string[] = []
widgets?
PdfDict[] = []
Returns
PdfRadioGroup
Overrides
Properties
dict
protectedreadonlydict: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
fieldType
readonlyfieldType:FieldType='radio'
Defined in: src/form/fields/radioGroup.ts:35
Discriminator for the concrete field type.
Overrides
name
readonlyname:string
Defined in: src/form/pdfField.ts:158
The fully-qualified field name.
Inherited from
parentNames
protectedreadonlyparentNames:string[]
Defined in: src/form/pdfField.ts:173
Parent field dictionary chain for building full names.
Inherited from
widgetDict
protectedreadonlywidgetDict: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
Methods
addToPage()
addToPage(
page):void
Defined in: src/form/fields/radioGroup.ts:62
Add all radio button widgets to a page.
Unlike other field types that have a single widget, a radio group has multiple widget annotations (one per option). This override adds all of them.
Parameters
page
Returns
void
Overrides
disableExporting()
disableExporting():
void
Defined in: src/form/pdfField.ts:271
Disable exporting this field (set the NoExport flag).
Returns
void
Inherited from
enableExporting()
enableExporting():
void
Defined in: src/form/pdfField.ts:266
Enable exporting this field (clear the NoExport flag).
Returns
void
Inherited from
generateAppearance()
generateAppearance():
PdfStream
Defined in: src/form/fields/radioGroup.ts:172
Generate the appearance stream for the first widget. For full appearance generation, use generateAppearanceForWidget().
Returns
Overrides
getFieldFlags()
protectedgetFieldFlags():number
Defined in: src/form/pdfField.ts:211
Get the raw /Ff (field flags) integer value.
Returns
number
Inherited from
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
getName()
getName():
string
Defined in: src/form/pdfField.ts:192
Get the partial field name (/T entry).
Returns
string
Inherited from
getOptions()
getOptions():
string[]
Defined in: src/form/fields/radioGroup.ts:113
Get the list of option names available in this radio group. Derived from the /AP /N dictionaries of each widget.
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
getSelected()
getSelected():
string|undefined
Defined in: src/form/fields/radioGroup.ts:82
Get the currently selected option name. Returns undefined if no option is selected.
Returns
string | undefined
getValue()
getValue():
string
Defined in: src/form/fields/radioGroup.ts:130
Get the value: the selected option name or undefined.
Returns
string
Overrides
getWidgets()
getWidgets():
PdfDict[]
Defined in: src/form/fields/radioGroup.ts:125
Get the widget annotation dictionaries.
Returns
PdfDict[]
hasFlag()
protectedhasFlag(flag):boolean
Defined in: src/form/pdfField.ts:221
Check if a specific flag bit is set.
Parameters
flag
number
Returns
boolean
Inherited from
isExported()
isExported():
boolean
Defined in: src/form/pdfField.ts:261
Whether the field is exported (inverse of NoExport flag).
Returns
boolean
Inherited from
isNoExport()
isNoExport():
boolean
Defined in: src/form/pdfField.ts:256
Whether the field should not be exported.
Returns
boolean
Inherited from
isReadOnly()
isReadOnly():
boolean
Defined in: src/form/pdfField.ts:236
Whether the field is read-only.
Returns
boolean
Inherited from
isRequired()
isRequired():
boolean
Defined in: src/form/pdfField.ts:246
Whether the field is required.
Returns
boolean
Inherited from
select()
select(
optionName):void
Defined in: src/form/fields/radioGroup.ts:94
Select an option by its name.
Sets /V on the field and updates /AS on each widget to show the correct appearance state.
Parameters
optionName
string
Returns
void
setFieldFlags()
protectedsetFieldFlags(flags):void
Defined in: src/form/pdfField.ts:216
Set the raw /Ff (field flags) integer value.
Parameters
flags
number
Returns
void
Inherited from
setFlag()
protectedsetFlag(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
setReadOnly()
setReadOnly(
readOnly):void
Defined in: src/form/pdfField.ts:241
Set the read-only flag.
Parameters
readOnly
boolean
Returns
void
Inherited from
setRequired()
setRequired(
required):void
Defined in: src/form/pdfField.ts:251
Set the required flag.
Parameters
required
boolean
Returns
void
Inherited from
setValue()
setValue(
value):void
Defined in: src/form/fields/radioGroup.ts:135
Set the value: select the named option.
Parameters
value
string | boolean | string[]
Returns
void