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

Free Support Forum - aspose.com

Looking to Purchase your PDF solution

We are needing the ability to lock / protect the PDF from modifications as well as allow for a digital signature of same document.

Thanks in advance.

@glabs

Thank you for contacting support.

Please try below code snippet in your environment and then share your kind feedback with us. It sets permissions for the PDF file while encrypting it for protection.

        //Open source document
        Document document = new Document(dataDir + "Example.pdf");
        Permissions Permission = new Permissions();
        Permission = Permissions.FillForm;
        document.Encrypt("", "owner", Permission, CryptoAlgorithm.AESx128);
        //Save resulting PDF document
        document.Save(dataDir + "Test.pdf");

We hope this will be helpful. Please feel free to contact us if you need any further assistance.

Thank you. Trying out your recommendation.

@glabs

Please take your time and get back to us as per your convenience.

Well, it works like you said. The password is an issue. Can this library lock / secure the document without using owner or user passwords?

Thank you.

@glabs

If you want to secure a PDF document without setting a password, then please try using below code snippet in your environment and share your kind feedback with us.

//Open source document
Document document = new Document(dataDir + "Test.pdf");

//Forbid all privileges on the document
DocumentPrivilege privilege = DocumentPrivilege.ForbidAll;

//Allow the fill privilege
privilege.AllowFillIn = true;

//Set the desired privileges
PdfFileSecurity fileSecurity = new PdfFileSecurity(document);
fileSecurity.SetPrivilege(privilege);

//Save resulting PDF document
document.Save(dataDir + "TestingPDF.pdf");

Please let us know if you need any further assistance. We will be more than happy to assist you.