question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot set property 'Annots' of undefined

See original GitHub issue

`const signer = require(‘node-signpdf’).default; const fs = require(‘fs’); const { addSignaturePlaceholder } = require(‘./node-signpdf-master/dist/helpers’); const PDFDocument = require(‘pdfkit’);

const createPdf = (params = { placeholder: { reason : ‘Digital signed by my key’ }, text: ‘this is content pdf’, }) => new Promise((resolve) => { const pdf = new PDFDocument({ autoFirstPage: true, size: ‘A4’, layout: ‘portrait’, bufferPages: true, }); pdf.info.CreationDate = ‘’; pdf.fillColor(‘#333’).fontSize(25).moveDown().text(params.text);

const pdfChunks = []; pdf.on(‘data’, (data) => { pdfChunks.push(data); }); pdf.on(‘end’, () => { resolve(Buffer.concat(pdfChunks)); });

const refs = addSignaturePlaceholder({ pdf, reason: ‘I am the author’, …params.placeholder, });

Object.keys(refs).forEach(key => refs[key].end()); pdf.end();

});

const action = async () => { let pdfBuffer = await createPdf(); let p12Buffer = fs.readFileSync(__dirname + ‘/baominh.key.p12’)

let pdf = signer.sign(pdfBuffer, p12Buffer, { passphrase : ‘12345678’, asn1StrictParsing : true }); fs.writeFileSync(__dirname + ‘/demo.pdf’, pdf); }

action();` Hello! I have been the error: ‘Cannot set property ‘Annots’ of undefined’ when i runed the code above. Can you help me with this?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
vbuchcommented, Feb 20, 2019

Here is what I did to make it work with 0.9.0: https://github.com/vbuch/node-signpdf/commit/3755311b32592a165c0a9c3ed7c7cfeac76e8ff4

Some kind of fix will surely be needed for this and it should go with a next release.

Separate note: Another thing that needs to happen in that release is fix babel ->… braces vulnerabilities reported by npm and/or yarn. And… while looking at the npm audit I saw that pdfkit also has a vulnerable dep that will need to get upgraded. So… we have some time until the pdfkit team resolves their vulnerability. Once they do, we’ll also need to have a ready fix for the 0.9 issue we’re discussing here.

Another separate note: There should be a nicer way to add annotations in a page. I’m basing this assumption on this code: https://github.com/foliojs/pdfkit/blob/5d527a32c87955f636b4220ad983dec208b4ffeb/lib/mixins/annotations.js So hopefully this can be improved as well for the next release. Should be something like pdfDocument.annotate({…annotation configuration})

0reactions
vbuchcommented, Jul 22, 2019

This has rolled out into 1.0.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript - cannot set property of undefined - Stack Overflow
Uncaught TypeError : Cannot set property 'greeting' of undefined. I'm trying to do something similar to an associative array. Why isn't this working?...
Read more >
ERROR: Cannot read property 'uuid' of undefined and annot ...
Hi folks Recently I have an issue when enter Consultation panel. There will be an error like this come up (not all at...
Read more >
Cannot set property 'privateKey' of undefined - Box Support
I use the commend box folders:get 0 -vI got this error, but the private.pem exists in the path.Can you help me with the...
Read more >
Handling Events - React
Another difference is that you cannot return false to prevent default behavior in ... handleClick and pass it to onClick , this will...
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError : Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found