You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get the following error when trying to sign a document using @signpdf module. Can anyone please help me regarding this issue?
This is the code I use:
const{onRequest}=require("firebase-functions/v2/https");const{onObjectFinalized}=require("firebase-functions/v2/storage");constadmin=require('firebase-admin')const{initializeApp}=require("firebase-admin/app");const{getStorage}=require("firebase-admin/storage");constlogger=require("firebase-functions/logger");constpath=require('path');const{setGlobalOptions}=require("firebase-functions/v2");constgetRawBody=require('raw-body')varpdflibAddPlaceholder=require('@signpdf/placeholder-pdf-lib').pdflibAddPlaceholder;varsignpdf=require('@signpdf/signpdf').default;varP12Signer=require('@signpdf/signer-p12').P12Signer;var{SUBFILTER_ETSI_CADES_DETACHED}=require('@signpdf/utils');varPDFDocument=require('pdf-lib').PDFDocument;var{ StandardFonts }=require('@pdf-lib/standard-fonts');setGlobalOptions({region: "europe-west1"});initializeApp();exports.processPDF=onObjectFinalized({},async(event)=>{constbucket=admin.storage().bucket()constfileBucket=event.data.bucket;// Storage bucket containing the file.constfilePath=event.data.name;// File path in the bucket.constcontentType=event.data.contentType;// File content type.console.log(filePath);constcertificatePath="/certificate/client-identity.p12";constfile=bucket.file(filePath);constcertificateFile=bucket.file(certificatePath);constfileDir=path.dirname(filePath);constfileBasename=path.basename(filePath);console.log(fileDir);if(fileDir!='uploads'){return;}//Only continue if the file is uploaded into uploads foldergetRawBody(file.createReadStream()).then((pdfBuffer)=>{console.log(pdfBuffer.length+' bytes submitted');getRawBody(certificateFile.createReadStream()).then((certBuff)=>{console.log(certBuff.length+'bytes cert');PDFDocument.load(pdfBuffer).then(function(pdfDoc){console.log("loading pdf document");console.log(pdfDoc);varsigner=newP12Signer(certBuff,{passphrase: "123456"});//This is the password's certificatepdflibAddPlaceholder({pdfDoc: pdfDoc,reason: 'The user is declaring consent through JavaScript.',contactInfo: '[email protected]',name: 'John Doe',location: 'Free Text Str., Free World',});pdfDoc.save().then(function(pdfWithPlaceholderBytes){// And finally sign the document.signpdf.sign(pdfWithPlaceholderBytes,signer).then(function(signedPdf){console.log('Signed PDF');})})});}).catch((err)=>{console.log(err.message);});}).catch((err)=>{console.log(err.message);});});
The error is the following:
TypeError: Cannot read properties of undefined (reading 'push')
> at pdflibAddPlaceholder (/Users/Desktop/docSignLocal/node_modules/@signpdf/placeholder-pdf-lib/dist/pdflibAddPlaceholder.js:174:10)
> at /Users/Desktop/docSignLocal/functions/index.js:51:25
> at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
I tried different libraries for signing a pdf file but none work. The error is "Cannot read properties of undefined (reading 'push')" when using @signpdf module. I need the document to be signed using the placeholder and signer. Thanks!
The text was updated successfully, but these errors were encountered:
Unfortunately the pdf-lib dependency hasn't been updated in over 2 years. I've been looking for a solution too, and while this node-signpdf does a nice job of its purpose of showing how to sign a typical PDF, it isn't a production-ready library for a full range of existing PDFs.
I get the following error when trying to sign a document using @signpdf module. Can anyone please help me regarding this issue?
This is the code I use:
The error is the following:
I tried different libraries for signing a pdf file but none work. The error is "Cannot read properties of undefined (reading 'push')" when using @signpdf module. I need the document to be signed using the placeholder and signer. Thanks!
The text was updated successfully, but these errors were encountered: