The Docotic.Pdf library can be used to protect PDF files with a password.
Here is a sample code for your task:
Dim filesToProcess As String() ' populate filesToProcess somehow For Each fileName As String In filesToProcess Using pdf As New PdfDocument(fileName) ' use OwnerPassword property if you need to protect file from being modified ' use UserPassword property if you need to protect file from being modified and from being viewed without knowing the password pdf.UserPassword = "password" ' there is also another supported encryption algorithms pdf.Encryption = PdfEncryptionAlgorithm.Aes128Bit Dim savePath As String = fileName & "encrypted.pdf" pdf.Save(savePath) End Using Next
You can also set permissions for any protected PDF file.
Disclaimer: I work for a library provider.
source share