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
importfsfrom'fs';importpathfrom'path';import{fileURLToPath}from'url'import{PDFDocument}from'pdf-lib';import{pdflibAddPlaceholder}from'@signpdf/placeholder-pdf-lib';importsignpdffrom'@signpdf/signpdf';import{P12Signer}from'@signpdf/signer-p12';const__dirname=fileURLToPath(newURL('.',import.meta.url))functionwork(){// contributing.pdf is the file that is going to be signedvarsourcePath=path.join(__dirname,'../documents/EPOS-en.pdf');varpdfBuffer=fs.readFileSync(sourcePath);console.log("Correct inputs",sourcePath,pdfBuffer)// certificate.p12 is the certificate that is going to be used to signvarcertificatePath=path.join(__dirname,'../documents/signing-certificate.p12');varcertificateBuffer=fs.readFileSync(certificatePath);varsigner=newP12Signer(certificateBuffer);// Load the document into PDF-LIBPDFDocument.load(pdfBuffer).then(function(pdfDoc){// Add a placeholder for a signature.pdflibAddPlaceholder({pdfDoc: pdfDoc,reason: 'The user is declaring consent through JavaScript.',contactInfo: 'signpdf@example.com',name: 'John Doe',location: 'Free Text Str., Free World',});// Get the modified PDFDocument bytespdfDoc.save().then(function(pdfWithPlaceholderBytes){// And finally sign the document.signpdf.sign(pdfWithPlaceholderBytes,signer).then(function(signedPdf){// signedPdf is a Buffer of an electronically signed PDF. Store it.vartargetPath=path.join(__dirname,'./pdf-lib.pdf');fs.writeFileSync(targetPath,signedPdf);})})})}work();
The text was updated successfully, but these errors were encountered:
Cannot add sing-placeholder in the pdf
A clear and concise description of what the bug is.
Output
Using you example and does not wor
The text was updated successfully, but these errors were encountered: