vizicsaba89 / pdf-signer

sign pdf documents
MIT License
37 stars 33 forks source link

Problems with PDFs > v1.3 #16

Closed NoahCardoza closed 3 years ago

NoahCardoza commented 3 years ago

It seems that this lib has problems working with fillable PDFs:

(node:24914) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'split' of undefined
    at getXref (/Users/vulcan/tmp/ns/node_modules/pdf-signer/dist/pdf/node-signpdf/read-pdf.js:84:34)
    at getFullXrefTable (/Users/vulcan/tmp/ns/node_modules/pdf-signer/dist/pdf/node-signpdf/read-pdf.js:63:25)
    at readRefTable (/Users/vulcan/tmp/ns/node_modules/pdf-signer/dist/pdf/node-signpdf/read-pdf.js:45:25)
    at Object.readPdf [as default] (/Users/vulcan/tmp/ns/node_modules/pdf-signer/dist/pdf/node-signpdf/read-pdf.js:23:20)
    at /Users/vulcan/tmp/ns/node_modules/pdf-signer/dist/pdf/node-signpdf/plain-add-placeholder.js:61:46
    at step (/Users/vulcan/tmp/ns/node_modules/pdf-signer/dist/pdf/node-signpdf/plain-add-placeholder.js:33:23)
    at Object.next (/Users/vulcan/tmp/ns/node_modules/pdf-signer/dist/pdf/node-signpdf/plain-add-placeholder.js:14:53)
    at /Users/vulcan/tmp/ns/node_modules/pdf-signer/dist/pdf/node-signpdf/plain-add-placeholder.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/vulcan/tmp/ns/node_modules/pdf-signer/dist/pdf/node-signpdf/plain-add-placeholder.js:4:12)

From the stack it seems that it's a problem with node-signpdf, so I'll also open an issue there. If you have any insight as to what might be causing this I'd be happy to try and work on a fix.

NoahCardoza commented 3 years ago

I just created an example repo so you can easily see what I'm working with!

NoahCardoza commented 3 years ago

After further research, while it does seem to be a problem with the lib not being able to read newer PDFs, I found a simple work around for the time being:

pdftk input.pdf output output.pdf

Is able add the proper trailer to the end of the PDF. In my case the PDF was also protected, so I used:

qpdf --decrypt encrypted.pdf unencrypted.pdf
pdftk unencrypted.pdf output output.pdf

Note: This was able to preserve the form fields!

I hope this helps someone else and saves them the 3 days it took me!

saargospa commented 3 years ago

Is this fixed in any branch ? Actually master doesn't work on PDF > v1.3 , it brokes on 1.7 for example

pankucsi commented 3 years ago

No it is not fixed and it is not a bug. Unfortunately we are not compatible with the new pdf version. You can solve this if you are downgrade the PDF's version.

You can read more about the problem in this issue if you are interested in it: https://github.com/vizicsaba89/pdf-signer/issues/17

dabi07ravi commented 1 year ago

how to show the green tick validation through this library