Remove Document Open and Permission Password

Hi

I am using your provided method for changing password

But now I have following 3 questions, Can you please provide me any method for doing it with example

1. Remove only Document Open Password

2. Remove only Permission Password

3. Remove both passwords at same time

Thanks

Hardik

Hi,

Please use the following code:

//Set both password

PdfFileSecurity fileSecurity1 = new PdfFileSecurity("orignal.pdf", "encrypted.pdf");

fileSecurity1.EncryptFile("userpassword", "ownerpassword", PdfPrivilege.Copy | PdfPrivilege.Print, true);

//Remove both password

PdfFileSecurity fileSecurity2 = new PdfFileSecurity("encrypted.pdf", "nopassword.pdf");

fileSecurity2.DecryptFile("ownerpassword");

//Remove open document password

PdfFileSecurity fileSecurity3 = new PdfFileSecurity("encrypted.pdf", "noopenpassword.pdf");

fileSecurity3.ChangePassword("ownerpassword", "", "ownerpassword");

//Remove permission password

PdfFileSecurity fileSecurity4 = new PdfFileSecurity("encrypted.pdf", "nopermissionpassword.pdf");

fileSecurity4.ChangePassword("ownerpassword", "userpassword", "");

Thanks.

Hy thanks for answers,

Now When I tried last two options, Its throwing "Bad Password" Error

Can you please help me?

What should I do if the input document doesn't have permission password, It has only openpassword?

Thanks

Hi,

I there is no password then simply pass an empty string "".

Thanks.

Hi That works <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

1 more Question

When we try Decrypt a file which has both open and permission password,

Which password we have to take for decrypting file prior to other one

Thanks

Hi,

You have to provide the owner password.

Thanks.