Sparticuz / node-qpdf2

A Content Preserving transformations on PDFs wrapped around QPDF
MIT License
20 stars 16 forks source link

feat: add option to decrypt without password #23

Closed mobihack closed 2 years ago

mobihack commented 2 years ago

Sometimes, downloaded pdf (such as your bank statements) are secured/encrypted by default. We can decrypt this even without OWNER password using qpdf.

qpdf --decrypt <source-pdf> <destination-pdf>

By using the ignorePassword prop in payload, we can remove the password from the process call. Didn't change the default procedure of sending "" as password to maintain backwards compatibility.

mobihack commented 2 years ago

Updated documentation for the same.

Sparticuz commented 2 years ago

Sorry I haven't looked at this yet. I'm trying to remember why we needed to send "" in the first place. According to https://stackoverflow.com/questions/42785645/qpdf-fails-to-encrypt-without-passwords the "" is needed for encryption without a password, however, nothing states that we need "" for decryption as well, and my initial testing shows that I don't think it's needed. Not sending the "" seems to be the same as not even including it. We might be able to remove it altogether and not need to add ignorePassword. What do you think?

Sparticuz commented 2 years ago

@mobihack Thanks for the PR! I've addressed this with v4.0

mobihack commented 2 years ago

I thought you added the empty string as default password foreseeing something I didn't understand.

Thank you for adding this feature @Sparticuz . Hope you have a nice day.