Removing "content extraction" permissions from PDF files.

Q: I use the following code snippet to remove "content extraction"
permissions from PDF files.

Please let me know if this is the correct technique for achieving this
on any valid PDF file. Please keep in mind that I only want to update
the file if "content extraction" is currently not allowed.

       private string CheckPDFRestrictions(string fileName, bool
displayMsg)
        {
            // There are too many conflicts with the System namespace
            // to include pdftron namespaces in the using section
            pdftron.PDF.PDFDoc doc = null;
            string newFileName = "";
            pdftron.SDF.StdSecurityHandler new_handler = null;
            pdftron.SDF.SecurityHandler secHdl = null;

            try
            {
                pdftron.PDFNet.Initialize();
                pdftron.PDFNet.SetResourcesPath("");

                // Default to current file name
                newFileName = fileName;

                // Create PDFTron document
                doc = new pdftron.PDF.PDFDoc(fileName);

                // Initialize security handler for document
                if (!doc.InitSecurityHandler())
                {
                    throw new MyException("PDF file is password
protected.");
                }

                // Check if the document is encrypted
                if (doc.IsEncrypted())
                {
                    secHdl = doc.GetSecurityHandler();

                    if
(!secHdl.GetPermission(pdftron.SDF.SecurityHandler.Permission.e_extract_content))
                    {
                        if (displayMsg)
                        {
                            UpdateStatusMessage("Updating PDF security
settings...");
                        }

                        // Create new file name
                        newFileName = _busLogic.TempDirectory;
                        newFileName +=
DateTime.Now.ToString("yyyyMMdd_HHmmss_ffffff") + ".pdf";

                        // Build new security handler
                        new_handler = new
pdftron.SDF.StdSecurityHandler();

new_handler.SetPermission(pdftron.SDF.SecurityHandler.Permission.e_extract_content,
true);
                        //new_handler.ChangeUserPassword(new
System.Text.UTF8Encoding().GetBytes(""));
                        doc.SetSecurityHandler(new_handler);

                        // Save the new document
                        doc.Save(newFileName, 0);

                        // Delete the old document
                        File.Delete(fileName);
                    }
                }

                doc.Close();

                return newFileName;
            }
            catch (Exception ex)
            {
                   throw new MyException("Unable to check PDF file
restrictions.", ex);
            }
        }
------

A:
I quickly went over your code and everything seems to be alright.
Instead of creating and setting a new StdSecurityHandler, you could
simply set the permission on the existing SecurityHandler. This way you
would preserve other security settings on the document (e.g. print,
document assembly, etc). Your current code essentially clears security
settings (see
'How do I remove PDF security?' -
http://www.pdftron.com/net/faq.html#enc_remove - for a shorter way to
implement the same functionality).