Using PdfFileSecurity’s method SetPrivilege(null, null. DocumentPrivilege) sets an owner password.
Hi Dvir,
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 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,