/open document Document document = new Document("input.pdf"); //encrypt PDF document.Encrypt("user", "owner", 0, CryptoAlgorithm.RC4x128);
How do I use this method to achieve upper desire outcome.
Any help would be appreciated !!!
/open document Document document = new Document("input.pdf"); //encrypt PDF document.Encrypt("user", "owner", 0, CryptoAlgorithm.RC4x128);
How do I use this method to achieve upper desire outcome.
Any help would be appreciated !!!
Hi Ankur,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Sorry for a delay in response.
I would request you to share some more details regarding your requirement. Are you interested in setting the document privileges using the second method (i.e using Aspose.Pdf DOM)? Please confirm so we can further investigate for this functionality. Regarding method 1 (using Facades), I think you are already able to set the security privileges as per your requirement. However, I modified the code a bit to setup the exact same options as per your screen shot for your reference:
//create DocumentPrivileges object
DocumentPrivilege privilege = DocumentPrivilege.ForbidAll;
privilege.PrintAllowLevel = 2;
privilege.ChangeAllowLevel = 1;
privilege.CopyAllowLevel = 2;
string file = @"d:\ap data\august2012\HelloWorld.pdf";
Document PdfDocument = new Document(file);
//create PdfFileSecurity object with input and output files
PdfFileSecurity fileSecurity = new PdfFileSecurity(PdfDocument);
//encrypt file using 128-bit encryption
fileSecurity.EncryptFile("userpassword", "ownerpassword", privilege, KeySize.x128, Algorithm.AES);
fileSecurity.Save(file);
Sorry for the inconvenience,
Hi,
document.Encrypt(“user”, “owner”, 0, CryptoAlgorithm.AESx128);
Hi Ankur,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thank you for the feedback.
I am glad to know that you are able to achieve your desired results with method 1. Regarding method 2, I am afraid setting DocumentPrivilege using Aspose.Pdf DOM is not supported at the moment. I have created a new feature request in our issue tracking system with issue id: PDFNEWNET-34170 for our development team to check and see if this can be implemented. As soon as I get a feedback, I will update you via this forum thread.
Sorry for the inconvenience,
The issues you have found earlier (filed as PDFNEWNET-34170) have been fixed in Aspose.Pdf for .NET 9.3.0.
Blog post for this release can be viewed over this link
Hi Ankur,
using (Document document = new Document(inputFile))<o:p></o:p>
{
DocumentPrivilege documentPrivilege = DocumentPrivilege.ForbidAll;
documentPrivilege.AllowScreenReaders = true;
documentPrivilege.AllowPrint = true;
document.Encrypt("user", "owner", documentPrivilege, CryptoAlgorithm.AESx128, false);
document.Save(outputFile);
}