I’m used to open unprotected PDF Files.
Now, I have to deal with Open-password protected ones, and I’m searching how to detect, before opening it, if a PDF file is protected.
Of course, I could try opening it without password, getting an error message and re-opening it with the password. I would prefer to ask for the password before trying to open the file.
Thanks for any idea using Xojo commands or MBS plugins, as well as Shell or other way.
An unsafe way to guess, that most of the time probably will do the job, is looking for the stream “/CreationDate(D:” (quotes excluded). If you find it, probably the doc is open. If encoded (password protected) the “D:” part is something else. Try it.
I imagine you could do this via the MBS DynaPDF plugin.
If you open the PDF with DynaPDFMBS class, you may get an error if your password is not right.
I know, but the question is “How?”.
Thanks for your reply.
Yes, I know that. And I found a way to manage the error, through the DynaPDFMBS error callback (Error event).
My goal was to check if a PDF file is protected before trying to OpenImport it. Could be a DynaPDF function checking the file or its header (or I don’t know what else), or a flag to set before OpenImporting, which could display the request for the password or returns a code “Hey, there is a password!”.
Is there something like this, or could it be coded?
Thanks a lot.