Lock pdf from from editing/tampering

we are using aspose words for our project for generating a PDF. is there a way to lock the PDF from getting edited by others?
some links that were found in search were not working.

@praveens96,

Thanks for your inquiry. With Aspose.Words you can encrypt the output PDF document using PdfSaveOptions.EncryptionDetails property. When this property is set to a valid PdfEncryptionDetails object, then the output PDF document will be encrypted. PdfEncryptionDetails class contains details for encrypting and access permissions for a PDF document.

Following code example demonstrates how to set permissions on a PDF document generated by Aspose.Words.

Document doc = new Document(MyDir + "Rendering.doc");

PdfSaveOptions saveOptions = new PdfSaveOptions();

// Create encryption details and set owner password.
PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails(string.Empty, "password", PdfEncryptionAlgorithm.RC4_128);

// Start by disallowing all permissions.
encryptionDetails.Permissions = PdfPermissions.DisallowAll;

// Extend permissions to allow editing or modifying annotations.
encryptionDetails.Permissions = PdfPermissions.ModifyAnnotations | PdfPermissions.DocumentAssembly;
saveOptions.EncryptionDetails = encryptionDetails;

// Render the document to PDF format with the specified permissions.
doc.Save(MyDir + "Rendering.SpecifyPermissions Out.pdf", saveOptions);

Thanks for the response. we have followed above steps and created PDF. when tried editing in online editiors, i was still able to edit. i dont want it to be password protected but just wanted to not be edited.

is there way to get that?

@praveens96,

Thanks for your inquiry. Please remove the following line of code from the code example shared in my previous post and let us know if you still face problem.

encryptionDetails.Permissions = PdfPermissions.ModifyAnnotations | PdfPermissions.DocumentAssembly;

If you still face problem, please share the following detail for testing.

  • Please share the online editor that you are using to modify the PDF.
  • Please ZIP and attach your input Word document.

We will investigate the issue and provide you more information on it.

Hi Manzoor, thanks for the response. we have commented that field and re-generated new pdf from word doc. we are still able to edit using: Easy to use Online PDF editor.

@praveens96,

Thanks for sharing the detail. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-16554. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@praveens96,

Thanks for your patience. It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-16554) as ‘Not a Bug’.

Here is the quote from PDF specification:

Note: Once the document has been opened and decrypted successfully, the application has access to the entire contents of the document. There is nothing inherent in PDF encryption that enforces the document permissions specified in the encryption dictionary. It is up to the implementors of PDF consumer applications to respect the intent of the document creator by restricting user access to an encrypted PDF file according to the permissions contained in the file.

Obviously https://www.sejda.com/pdf-editor does not respect the specified permissions.