I have a need to take pdf documents I have created in another process,
which are contained in a memory stream object, and are not on disk,
and simply encrypt them with a password. I would be doing this on a
single server, from a service I wrote, and doing it to dozens if not
hundreds of pdf documents each day.
You can use PDFNet SDK (www.pdftron.com/net) to secure/encrypt PDF
documents on the fly.
For an example of how to open & save PDF documents from memory buffer
please take a look at PDFDocMemory sample project (http://
For an example of how to encrypt existing PDF documents please take a
look at EncTest sample project (http://www.pdftron.com/net/
StdSecurityHandler new_handler = new StdSecurityHandler();
// Set a new password required to open a document
string my_password = "test";
// Set Permissions
new_handler.SetPermission (SecurityHandler.Permission.e_print, true);