How to remove PDF password security?

0
I want to remove the existing PDF password protection and I tried the following code. I do have the current password...
Somehow the id.Save fails raising the error code: "Hash not valid for use in specified state". 
 
It has something to do with setting the password on "string.Empty". If I remove these two lines, the save will succeed!
Am I doing something wrong? Can the passwords be set to string.Empty? Or is there another way?
 
 
[code lang='c#']              
PdfImportedDocument id = null;
id = new PdfImportedDocument(inputFilePath, password);
// Remove password
id.Security.OwnerPassword = string.Empty;
id.Security.UserPassword = string.Empty;
// Set print indicator to printable
if (!id.Security.Permissions.HasFlag(ComponentPro.Pdf.Security.PdfDocumentPermissions.Print))
{
       id.Security.SetPermissions(ComponentPro.Pdf.Security.PdfDocumentPermissions.Print);
}
id.Save(outputFilePath);
 [/code]
edited 12/3/2017 4:43:29 PM
asked 4/27/2014 4:34:25 PM
add a comment

1 Answers

0

Dear Sir,

It's still not possible to remove password of a protected one. The best way is to import the content of that PDF file to another one and save the new one. We will consider adding a function to create a new PDF document from a protected one.

 
answered 11/16/2017 12:41:37 AM
add a comment

Your Answer

Not the answer you're looking for? Browse other questions tagged pdf word or ask your own question.