PDF Encrypter

Continuing my adventure of “Going Paperless“, I needed an easy way to encrypt PDF files before I added them to Evernote. To do this, I used the LEADTOOLS PDFFile() class to add a user password to a file. I created a console application with code to register itself into the Windows Explorer shell. Now I can right click any PDF file and encrypt it with a password. The LEADTOOLS code to do this is very easy; it took me longer to figure out how to edit the registry to add the application to the Windows Explorer context menu then it did to use LEADTOOLS to add the password.

One call got it done:

new PDFFile( fileName, password ) {
   SecurityOptions = new PDFSecurityOptions {
      UserPassword = newPassword,
      EncryptionMode = PDFEncryptionMode.RC128Bit
   },
   CompatibilityLevel = PDFCompatibilityLevel.PDF15
}.Convert( 1, -1, null );

Clone, Fork, or Download the code from GitHub: Git the Code

Warning!

If you use this utility, do not forget the password you give for each file. If you do, then the PDF file will be useless. As a matter of fact, I am thinking about hard-coding the password in my code to prevent mistyping and to streamline the process even more. (At least until I have the 6 bankers boxes of files digitized.) Also, if the password is hard-coded, then I could write a simple batch file that encrypts the file and then uses ENScript.exe to add the file to my default Evernote notebook.

About 

Developer Advocate

This entry was posted in Document Imaging and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *