vbuch / node-signpdf

Simple signing of PDFs in node.
MIT License
688 stars 175 forks source link

Adding plain placeholder to PDF #113

Closed inane closed 3 years ago

inane commented 3 years ago

I am working with a feature that should be able to import a pdf document and to sign in a nodejs environment.

Here is my code, signing correctly thanks to your module but I am not being able to add a plain placeholder.

async function signDocument ( req, res ) {
  const passphrase = 'DA5cJvezM6Px6JLR',
        p12Buffer  = fs.readFileSync ( `${ __dirname }/WktYaXJlM1VOY0RxdG1kQw==.p12` ),
        payload    = {
          documento : req.file.path
        }
  let pdfBuffer    = fs.readFileSync ( req.file.path )

  pdfBuffer = plainAddPlaceholder ( {
    pdfBuffer,
    reason          : 'I have reviewed it.',
    signatureLength : 15544,

  } )
  pdfBuffer = signer.sign ( pdfBuffer, p12Buffer, { passphrase } )
  fs.writeFileSync ( `${ __dirname }/` + req.file.originalname, pdfBuffer )
  await models.Firma.create ( payload )
  response.successResponse ( req, res, req.body, 'DOCUMENT_SIGNED_SUCCESSFUL' )
}

I attach one dummy pdf to test. Basically I am adding a sign and I would like to add a placeholder with data.

Please help me with this topic. Thank you in advance. test.pdf

DvirH commented 3 years ago

I found out that you can't add a placeholder to an existing pdf using the pdfkit. But you can add a placeholder only by using the pdfkitPlaceHolder before the pdf is created. If you find a solution let me know

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had activity in the past 90 days. It will be closed if no further activity occurs. Thank you for your contributions.