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

Free Support Forum - aspose.com

Change the permissions on a generated PDF to Read only


I want to change the permissions of a pdf file to read only so that no one else can modify it, can you let me know how to do this using aspose-pdf java library


Thank you for contacting support.

You may set different privileges of DocumentPrivilege to false one by one, or ForbidAll at once as per your requirements. Please try using below code snippet in your environment and then share your kind feedback with us.

// Load source document
Document document = new Document(inputFile);

// Forbid all privileges on the document
DocumentPrivilege privilege = DocumentPrivilege.getForbidAll();

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

// Save resulting PDF document

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