Advanon / pdf-signatures

Nodejs package to sign pdfs with external electronic signatures (PKCS7)
GNU Affero General Public License v3.0
16 stars 6 forks source link

Signature is invalid #17

Open tomasantunes opened 2 years ago

tomasantunes commented 2 years ago

When I sign the PDF with an external signature I get the following error when reading it with Acrobat: "There are errors in the formatting or information contained in this signature."

Here is the code I used:

    var dt = new Date().getTime();
    var filename = __dirname + "\\output_pdf\\" + "fatura" + dt + ".pdf";

    var dt2 = new Date().toISOString();

    const outputPath = await addSignaturePlaceholderToPdf({
        file: pdfFile,
        out: filename,
        estimatedsize: 30000,
        certlevel: CertificationLevels.NotCertified,
        reason: 'I want to sign the document',
        location: 'Porto',
        contact: 'JOÃO SILVA',
        date: dt2,
      });

      var dt3 = new Date().getTime();
      var filename2 = __dirname + "\\output_pdf\\" + "fatura" + dt + "b.pdf";

      const outputPath2 = await signPdf({
        file: filename,
        out: filename2,
        signature: signature,
      });