Hello,
Is there a way to determine via Powershell if a particular pdf file (among many files) is password protected (either on open or editing, printing) before I even open the file?
Thanks,
Bernard
Technology Tips and News
Hello,
Is there a way to determine via Powershell if a particular pdf file (among many files) is password protected (either on open or editing, printing) before I even open the file?
Thanks,
Bernard
Is there a way to determine via Powershell if a particular pdf file (among many files) is password protected (either on open or editing, printing) before I even open the file?
The short answer: Yes, there is(!)
The longer answer: You would need to read the file into an array of bytes, then examine the first 80 bytes. If the file is encrypted then the file header appears to contain this string:
obj<</Length 6 0 R/Filter /FlateDecode>>stream
You would need to confirm in an Adobe forum if this is a reliable encryption indicator.