From 5398400ae626595579a41189ed774462573cc0f5 Mon Sep 17 00:00:00 2001 From: Valery Buchinsky Date: Mon, 13 Nov 2023 17:24:33 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20[placeholder-pdf-lib]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dist/pdflibAddPlaceholder.d.ts | 4 ++-- .../dist/pdflibAddPlaceholder.d.ts.map | 2 +- .../dist/pdflibAddPlaceholder.js | 15 ++++++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts b/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts index 36e54366..9fe977da 100644 --- a/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts +++ b/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts @@ -1,7 +1,7 @@ export function pdflibAddPlaceholder({ pdfDoc, reason, contactInfo, name, location, signatureLength, byteRangePlaceholder, subFilter, widgetRect, }: InputType): void; -export type PDFDocumentFactory = import('pdf-lib').PDFDocumentFactory; +export type PDFDocument = import('pdf-lib').PDFDocument; export type InputType = { - pdfDoc: any; + pdfDoc: PDFDocument; reason: string; contactInfo: string; name: string; diff --git a/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts.map b/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts.map index eac4ddcb..e7f0c921 100644 --- a/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts.map +++ b/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"pdflibAddPlaceholder.d.ts","sourceRoot":"","sources":["../src/pdflibAddPlaceholder.js"],"names":[],"mappings":"AA8BO,qJAHI,SAAS,GACP,IAAI,CAsEhB;iCA5FY,OAAO,SAAS,EAAE,kBAAkB;;;YAMpC,MAAM;iBACN,MAAM;UACN,MAAM;cACN,MAAM;sBACN,MAAM;2BACN,MAAM;;;;gBACN,MAAM"} \ No newline at end of file +{"version":3,"file":"pdflibAddPlaceholder.d.ts","sourceRoot":"","sources":["../src/pdflibAddPlaceholder.js"],"names":[],"mappings":"AAoCO,qJAHI,SAAS,GACP,IAAI,CAuEhB;0BA7FY,OAAO,SAAS,EAAE,WAAW;;YAK7B,WAAW;YACX,MAAM;iBACN,MAAM;UACN,MAAM;cACN,MAAM;sBACN,MAAM;2BACN,MAAM;;;;gBACN,MAAM"} \ No newline at end of file diff --git a/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.js b/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.js index 3cb48e33..af0dd76b 100644 --- a/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.js +++ b/packages/placeholder-pdf-lib/dist/pdflibAddPlaceholder.js @@ -7,12 +7,12 @@ exports.pdflibAddPlaceholder = void 0; var _utils = require("@signpdf/utils"); var _pdfLib = require("pdf-lib"); /** - * @typedef {import('pdf-lib').PDFDocumentFactory} PDFDocumentFactory + * @typedef {import('pdf-lib').PDFDocument} PDFDocument */ /** * @typedef {object} InputType -* @property {PDFDocumentFactory} pdfDoc +* @property {PDFDocument} pdfDoc * @property {string} reason * @property {string} contactInfo * @property {string} name @@ -69,6 +69,7 @@ const pdflibAddPlaceholder = ({ Name: _pdfLib.PDFString.of(name), Location: _pdfLib.PDFString.of(location) }, pdfDoc.index); + const signatureDictRef = pdfDoc.context.register(signatureDict); // Create the signature widget const rect = _pdfLib.PDFArray.withContext(pdfDoc.context); @@ -78,19 +79,19 @@ const pdflibAddPlaceholder = ({ Subtype: 'Widget', FT: 'Sig', Rect: rect, - V: signatureDict, + V: signatureDictRef, T: _pdfLib.PDFString.of('Signature1'), - F: 4, + F: _utils.ANNOTATION_FLAGS.PRINT, P: pages[0].ref }, pdfDoc.index); const widgetDictRef = pdfDoc.context.register(widgetDict); - // Annotate the widget + // Annotate the widget on the first page pages[0].node.set(_pdfLib.PDFName.of('Annots'), pdfDoc.context.obj([widgetDictRef])); - // Reference the widget in the AcroForm + // Reference the widget in the a new AcroForm pdfDoc.catalog.set(_pdfLib.PDFName.of('AcroForm'), pdfDoc.context.obj({ - SigFlags: 3, + SigFlags: _utils.SIG_FLAGS.SIGNATURES_EXIST | _utils.SIG_FLAGS.APPEND_ONLY, Fields: [widgetDictRef] })); };