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
            // 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;


                // 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

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

                        if (displayMsg)
                            UpdateStatusMessage("Updating PDF security

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

                        // Build new security handler
                        new_handler = new


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

                        // Delete the old document


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

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?' - - for a shorter way to
implement the same functionality).