How to Make Password protected PDf

Hi All,
I am using vb.net coding for aspose pdf.Right now I saved pdf file to file system as well.

I want to make that pdf file to be password protected one.So can you please give the code for making the pdf file password protection.

Hope you all understand my requirements.
thanks in advance

Hi there,

Thanks for your inquiry. Please check the following VB code snippet and documentation link for encrypting PDF files. Hopefully, it will help you to accomplish the task.

'open document
Dim document As New Document("input.pdf")

' encrypt PDF
document.Encrypt("user", "owner", 0, CryptoAlgorithm.RC4x128)

' save updated PDF
document.Save("output.pdf")

Pleas feel free to contact us for any further assistance

Best Regards,