* 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 = {})
| 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. |
no test coverage detected