MCPcopy Create free account
hub / github.com/LibPDF-js/core / createFormField

Function createFormField

src/document/forms/fields/factory.ts:25–63  ·  view source on GitHub ↗
(
  dict: PdfDict,
  ref: PdfRef | null,
  registry: ObjectRegistry,
  acroForm: AcroFormLike,
  name: string,
)

Source from the content-addressed store, hash-verified

23 * Non-terminal fields (containers) are created directly in AcroForm.
24 */
25export 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.

Callers 8

loadMethod · 0.90
collectFieldsMethod · 0.90
createSignatureFieldMethod · 0.90
createTextFieldMethod · 0.90
createCheckboxMethod · 0.90
createRadioGroupMethod · 0.90
createDropdownMethod · 0.90
createListboxMethod · 0.90

Calls 2

getInheritableFieldNameFunction · 0.85

Tested by

no test coverage detected