Using PdfFileSecurity’s method SetPrivilege(null, null. DocumentPrivilege) sets an owner password.
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
any progress?
Hi Dvir,
What do you mean by “sets null password”?
Mybe your version of Adobe Reader lets you change null edit password
dvirP:
Mybe your version of Adobe Reader lets you change null edit passwordMine just shows that the pdf document is locked for editing
Hi Dvir,
Hi,
tilal.ahmad:
Hi Dvir,dvirP:
Mybe your version of Adobe Reader lets you change null edit passwordMine just shows that the pdf document is locked for editingThanks 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,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,
Hi,
Hi Dvir,
Thanks for your inquiry. You can decrypt a PDF document and set “no security” by following these instructions. I hope this helps you accomplish the task!
You need to Decrypt a PDF by calling:
Aspose.Pdf.Securing.DecryptFile(string OwnerPassword)
.
Hopefully it will help you to accomplish the task,
// Your code block here, re-written in a clean format by removing unwanted HTML Tags <o:p></o:p>/ Making sure correct definition of classes.
//create DocumentPrivileges object
DocumentPrivilege privilege = DocumentPrivilege.ForbidAll;
privilege.ChangeAllowLevel = 1;
privilege.AllowPrint = true;
privilege.AllowCopy = true;
PdfFileSecurity fileSecurity = new PdfFileSecurity();
//open PDF document
//open document
fileSecurity.BindPdf(myDir + "TableResult.pdf");
fileSecurity.Save(myDir + "ProfileTemplate_Priveleged.pdf");
fileSecurity.DecryptFile();
//open decrypted file now if required to decrypt again for save without security
//open document again if you require again to decrypt with save same file as before code without pdf creation again without security
fileSecurity = new PdfFileSecurity();
Please feel free to contact us for any further assistance.
Best Regards,