We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Lock down pdf

After my MVC creates the pdf, the pdf can be edited in Acrobat. I want to lock the pdf so no one can edit the pdf, only view, save and print pdf. How do I lock the pdf in C#?


Please try the following code which restricts all permissions except printing. Let us know if this satisfies your requirements.

Document doc = new Document(dataDir + "Sample.PDF");
SaveOptions option = new PdfSaveOptions();
Permissions Permission = new Permissions();
string password = string.Empty;
Permission = Permissions.PrintDocument;
doc.Encrypt(password, "password", Permission, CryptoAlgorithm.AESx128);
doc.Save(dataDir + "Secured.PDF", option);

Yes, that worked. Thank you.