( dict: PdfDict, ref: PdfRef | null, registry: ObjectRegistry, acroForm: AcroFormLike, name: string, )
| 23 | * Non-terminal fields (containers) are created directly in AcroForm. |
| 24 | */ |
| 25 | export function createFormField( |
| 26 | dict: PdfDict, |
| 27 | ref: PdfRef | null, |
| 28 | registry: ObjectRegistry, |
| 29 | acroForm: AcroFormLike, |
| 30 | name: string, |
| 31 | ): TerminalField { |
| 32 | const ft = getInheritableFieldName(dict, "FT", registry); |
| 33 | const ff = getInheritableFieldNumber(dict, "Ff", registry); |
| 34 | |
| 35 | switch (ft) { |
| 36 | case "Tx": |
| 37 | return new TextField(dict, ref, registry, acroForm, name); |
| 38 | |
| 39 | case "Btn": |
| 40 | if (ff & FieldFlags.PUSHBUTTON) { |
| 41 | return new ButtonField(dict, ref, registry, acroForm, name); |
| 42 | } |
| 43 | |
| 44 | if (ff & FieldFlags.RADIO) { |
| 45 | return new RadioField(dict, ref, registry, acroForm, name); |
| 46 | } |
| 47 | |
| 48 | return new CheckboxField(dict, ref, registry, acroForm, name); |
| 49 | |
| 50 | case "Ch": |
| 51 | if (ff & FieldFlags.COMBO) { |
| 52 | return new DropdownField(dict, ref, registry, acroForm, name); |
| 53 | } |
| 54 | |
| 55 | return new ListBoxField(dict, ref, registry, acroForm, name); |
| 56 | |
| 57 | case "Sig": |
| 58 | return new SignatureField(dict, ref, registry, acroForm, name); |
| 59 | |
| 60 | default: |
| 61 | return new UnknownField(dict, ref, registry, acroForm, name); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Get inheritable name value from field hierarchy. |
no test coverage detected