PDF passwords and security

Q: Our application allows a user to add/remove pages to and from different PDFs. For example, a user could potentially upload a password protected PDF, then move one page from that PDF to another PDF. Then we rely on PDFNet to save the new byte arrays for the two PDFs. Can PDFNet move pages from a secured PDF to an open PDF, and save the byte arrays FOR BOTH PDFDoc Objects? These new byte arrays need to be used then in the future to reconstruct a PDFDoc object, which may be manipulated further.

You said: " You can identify documents that require open pass with

InitSecurityHandler() as shown in EncTest sample". That sample looks like if the PDFDoc.InitSecurityHandler() method call returns false, then a password is required. Is that correct?

A: A PDF document can be secured with 2 types of password: permission (owner) and user (open).

If document is secured with user (open) you need to provide the pass in order to open the file and there is no way around it.

If document is secured with just a permission (owner) you don’t need to provide the pass in order to open the file.

You can identify documents that require open pass with InitSecurityHandler() as shown in EncTest sample.

Unfortunately in PDF, encryption works on a document and not on a page level - so you can’t (easily) manipulate pages on a page level without need for pass.

PDFDoc.InitSecurityHandler() method call returns false, then a password is required. Is that correct?

Correct.

Q:

Thanks for the information on password-protected PDFs. I do have another question. Say the user uploads a PDF, our code does a check to see if the InitSecurityHandler method returns false for a secured PDF, if it secured then the user is prompted for a password. Now we have the password for the secured PDF. Is there a way to use PDFNet to remove the password protection for the PDF or save a copy of the PDF that is not password-protected?

A:

Yes, this is possible. Simply use pdfdoc.RemoveSecurity(), than save the document using pdfdoc.Save(…).