Welcome Guest Search | Active Topics | Sign In | Register

PDF decryption problem Options
Tom
Posted: Thursday, May 2, 2013 4:06:32 PM
Rank: Newbie
Groups: Member

Joined: 5/2/2013
Posts: 1
I am trying to remove existing security and add a different password. Basically, I want to remove the user password and replace the owner password. The following code does not work, the existing user password remains:

Code: C#
PdfDocumentSecurity security = new PdfDocumentSecurity("123");
PdfDocument doc = new PdfDocument(file, security);
doc.Save(Path.Combine(encryptedPath, baseFileName));


I have tried removing the old password and replacing the owner password in one step by overwriting the existing file, saving the PDF to a new directory between these two steps, setting the user pass to an empty string, nothing. The user pass persist no mater what. Any help is appreciated.
eo_support
Posted: Friday, May 3, 2013 4:24:35 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

You have to explicitly clear the user password before resave it:

Code: C#
//Clear the user password
doc.Security.UserPassword = null;

//Save it
doc.Save(....);


Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.