Free Support Forum - aspose.com

PdfFileSecurity adding user password when non supplied

Using PdfFileSecurity’s method SetPrivilege(null, null. DocumentPrivilege) sets an owner password.

I remember testing it a few months ago and it did not set a password which means sometime in the last few months the behaviour changed.
further more, what password is it setting if the input password is null???

Hi Dvir,


Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 10.5.0 where I have used following code snippet and as per my observations, when viewing resultant document, I am unable to notice any prompt for password.

[C#]
//create
DocumentPrivileges object

DocumentPrivilege privilege = DocumentPrivilege.ForbidAll;

privilege.ChangeAllowLevel = 1;

privilege.AllowPrint = true;

privilege.AllowCopy = true;

//open PDF document

PdfFileSecurity fileSecurity = new PdfFileSecurity();

fileSecurity.BindPdf("c:/pdftest/CS.ProfileTemplate.pdf");

//set document privileges

fileSecurity.SetPrivilege(null,null,privilege);

fileSecurity.Save(“c:/pdftest/CS.ProfileTemplate_Priveleged.pdf”);

It adds an editing password not a reading password

check the file’s info

any progress?

Hi Dvir,


We are sorry for delayed response. With above shared code, API sets null password for both open and edit document. If you want to make any change in document privileges then you need to set edit password first.

Moreover, when you set null edit password, Adobe allow you to open Change Setting window in Security tab. Otherwise it will not allow you to enter in Change Settings window without providing password.

Please feel free to contact us for any further assistance.

Best Regards,

What do you mean by “sets null password”?

if I pass null to edit password and open the document I see that the document has an editing password set for it, what’s the password???

Mybe your version of Adobe Reader lets you change null edit password

Mine just shows that the pdf document is locked for editing
Hi Dvir,

dvirP:
Mybe your version of Adobe Reader lets you change null edit password
Mine just shows that the pdf document is locked for editing

Thanks for your feedback. Yes I am using Adobe Acrobat XI for viewing PDF document and it is allowing me to open "Change Settings" window and reset null edit password. Can you please test the scenario in Adobe Acrobat and share the results.

Best Regards,

Hi Dvir,


In reference to your original question, edit password in result of null parameter , we have logged an investigation ticket PDFNEWNET-38948 in our issue tracking system. We will check it with our product team and will let you know the findings.

Moreover, in reference to your following findings, Can you please confirm the version you used for it? So we will investigate it further, as I have tried couple of old versions and unable to notice any difference.

"I remember testing it a few months ago and it did not set a password which means sometime in the last few months the behaviour changed."


Best Regards,

Hi,


I have tested my old version and it seems I was mistaken and this behaviour is persist in all my versions.
I probably didn’t notice the importance of it until I had a user that requested password status of PDFs so he wouldn’t handle locked PDFs and these documents with null edit passwords poped up as “locked”
tilal.ahmad:
Hi Dvir,

dvirP:
Mybe your version of Adobe Reader lets you change null edit password
Mine just shows that the pdf document is locked for editing

Thanks for your feedback. Yes I am using Adobe Acrobat XI for viewing PDF document and it is allowing me to open "Change Settings" window and reset null edit password. Can you please test the scenario in Adobe Acrobat and share the results.

Best Regards,

I only use Acrobat Reader which shows the pdf to be having editing password, the same as if I have added editing password
dvirP:
Hi,

I have tested my old version and it seems I was mistaken and this behaviour is persist in all my versions.
I probably didn't notice the importance of it until I had a user that requested password status of PDFs so he wouldn't handle locked PDFs and these documents with null edit passwords poped up as "locked"
Hi Dvir,

This scenario will surely be considered while resolving earlier reported issue.

Hi Dvir,


Thanks for your patience. We have investigated the issue and would like to update you that it is not a bug. PDF standard allows to set empty passwords so Aspose.Pdf do. In subjected scenario the PDF document has empty passwords, and if you wants to remove encryption then you can just set No security in Adobe Pro (attached images shows this feature). It’s possible because owner password is empty.

Moreover, Adobe Pro does not allow to complete document’s encryption without setting one of user or owner password.

Best Regards,

Hi,


thanks for the reply,

how do I change to “no security” programaticly using aspose.pdf?

Hi Dvir,


Thanks for your inquiry. You need to decrypt PDF document to set “no security” as following. Hopefully it will help you to accomplish the task.

//create DocumentPrivileges object<o:p></o:p>

DocumentPrivilege privilege = DocumentPrivilege.ForbidAll;

privilege.ChangeAllowLevel = 1;

privilege.AllowPrint = true;

privilege.AllowCopy = true;

//open PDF document

PdfFileSecurity fileSecurity = new PdfFileSecurity();

fileSecurity.BindPdf(myDir+"TableResult.pdf");

//set document privileges

fileSecurity.SetPrivilege(null, null, privilege);

fileSecurity.Save(myDir+"ProfileTemplate_Priveleged.pdf");

//decrypt PDF document for setting "no security"

//open document

fileSecurity = new PdfFileSecurity();

fileSecurity.BindPdf(myDir + "ProfileTemplate_Priveleged.pdf");

fileSecurity.DecryptFile(null);

fileSecurity.Save(myDir + "ProfileTemplate_decrypted.pdf");

Please feel free to contact us for any further assistance.


Best Regards,