vbuch / node-signpdf

Simple signing of PDFs in node.
MIT License
719 stars 178 forks source link

Able to sign PDFS with a trailer but NOT able to sign PDFs without a trailer #81

Closed mayurchoksi closed 4 years ago

mayurchoksi commented 4 years ago

Describe the bug and the expected behaviour I have a few PDFs that don't contain a trailer. It seems that PDFs with/without trailers are valid PDFs.

When I try to sign PDFs without a trailer using node-signpdf I get the following error: (node:51815) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'split' of undefined at getXref (/Users/folderX/node_modules/node-signpdf/dist/helpers/plainAddPlaceholder/readRefTable.js:55:34) at getFullXrefTable (/Users/folderX/node_modules/node-signpdf/dist/helpers/plainAddPlaceholder/readRefTable.js:79:25) at readRefTable (/Users/folderX/node_modules/node-signpdf/dist/helpers/plainAddPlaceholder/readRefTable.js:100:25) at readPdf (/Users/folderX/node_modules/node-signpdf/dist/helpers/plainAddPlaceholder/readPdf.js:31:46) at plainAddPlaceholder (/Users/folderX/node_modules/node-signpdf/dist/helpers/plainAddPlaceholder/index.js:54:37)

I am using version the following versions: "node-forge": "^0.9.1", "node-signpdf": "^1.2.3",

Sample code attached. index.txt

stale[bot] commented 4 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.

ghoshpushpendu commented 2 years ago

this issue occurs when you are using PDF-Lib to add or parse the PDF before the signing process.

{ useObjectStreams: false } to the save() method did the trick! in pdf-lib