Subject: How to remove PDF password security?
Date: 2014-04-27 16:34:25
From: sybren.kuperus@docsquare.nl
Source: remove-pdf-password-security
----------------------------------------------------------------------

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]
---------------------------------------------------------------------- Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor who sold you the license and ask for your money back. Back to ComponentPro Q&A Forum Index