Querying PDF document permissions.

Q: I have some documents that have restrictions for print or extracting
text. How can I determine what restrictions if any are applied to a
documents. I have implemented the MySecurityHandler. This is called
when there is a password to open the file. I have tried using the
GetSecurityHandler and then calling the method for GetPermission. If
the document has a password for viewing only, this works OK. If there
is no password, I get an unknown exception when calling the
GetPermission method. If the file has a password for viewing and has
restrictions for viewing or extracting, the GetAuthorizationData method
is called for each permission, but it always fails. Can you give me
some pointers on what I may be doing wrong or misunderstanding?

You can use sec_hdlr.Authorize(flag) to check specific permissions (for
a detailed example of how to check permission flags, please take a look
at 'DocPropSecurity.cpp' in the new PDFView for C++ sample project).

If document is not secured the security handler is most likely null.
You can use doc.IsEncrypted() to check that the document is associated
with a valid security handler.