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

Method createSignatureField

src/api/pdf-form.ts:472–505  ·  view source on GitHub ↗

* Create a new signature field. * * Creates an empty (unsigned) signature field that can later be signed. * The field is created with an empty /Kids array. Widget properties * (page, rect, etc.) are set by PDFSignature during signing. * * @param name - Field name (must be unique)

(name: string, options: SignatureFieldOptions = {})

Source from the content-addressed store, hash-verified

470 * ```
471 */
472 createSignatureField(name: string, options: SignatureFieldOptions = {}): SignatureField {
473 this.validateUniqueName(name);
474
475 // Create field dictionary with /Kids array (like other field types)
476 // Widget properties are added by PDFSignature during signing
477 const fieldDict = PdfDict.of({
478 FT: PdfName.of("Sig"),
479 T: PdfString.fromString(name),
480 Kids: new PdfArray([]),
481 });
482
483 // Store styling metadata (even though sig fields are usually invisible)
484 this.storeFieldStyling(fieldDict, options);
485
486 // Register the field and add to AcroForm
487 const fieldRef = this._ctx.registry.register(fieldDict);
488 this._acroForm.addField(fieldRef);
489
490 // Create the SignatureField instance
491 // oxlint-disable-next-line typescript/no-unsafe-type-assertion
492 const field = createFormField(
493 fieldDict,
494 fieldRef,
495 this._ctx.registry,
496 this._acroForm,
497 name,
498 ) as SignatureField;
499
500 // Add to cache
501 this.allFields.push(field);
502 this.fieldsByName.set(name, field);
503
504 return field;
505 }
506
507 /**
508 * Create a new text field.

Callers 4

prepareSignatureFieldMethod · 0.80
mainFunction · 0.80

Calls 9

validateUniqueNameMethod · 0.95
storeFieldStylingMethod · 0.95
createFormFieldFunction · 0.90
addFieldMethod · 0.80
pushMethod · 0.80
ofMethod · 0.45
fromStringMethod · 0.45
registerMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected