How-to Sign already create PDF document
See original GitHub issueHi Guys,
Grate work… I’ll will appreciate to create and submit a demo of using node-signpdf for the ones using jsPDF. The problem is that I can not find how to create the placeholders as shows on the tests
const signature = pdf.ref({ Type: 'Sig', Filter: 'Adobe.PPKLite', SubFilter: 'adbe.pkcs7.detached', ByteRange: [ 0, DEFAULT_BYTE_RANGE_PLACEHOLDER, DEFAULT_BYTE_RANGE_PLACEHOLDER, DEFAULT_BYTE_RANGE_PLACEHOLDER, ], Contents: Buffer.from(String.fromCharCode(0).repeat(signatureLength)), Reason: new String(reason), // eslint-disable-line no-new-wrappers M: new Date(), });
When looking on the jsPDF I could not find the equivalent to pdf.ref, but I am sure there is a way to do that, any idea?
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (9 by maintainers)
Top GitHub Comments
I’ve started playing with this a bit: https://github.com/vbuch/node-signpdf/tree/play-with-trailers It’s hell lot of string/buffer operations that need to be done, but seems like it is doable at least to the bare minimum functionality. Will let you know once I have something working. This would enable adding signature placeholder to any PDF (currently only thinking about really limited options) so it won’t matter if you created your document with PdfKit, jsPDF or another tool. Not sure the code will be that readable so I will keep the pdfkit examples in the helpers somehow as well.
Heads up: What the ref function basically does in pdfkit is store an item an enumerate it. So just reading the trailer will give you the current number of items. Use that number for you next added item and increase the number in the trailer. Link the AcroForm in the root descriptor. That’s all you need to do. The pdf spec is available at http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf