Example #1
0
        // ------------------------------------------------------------------------------------------------------------

        /// <summary>
        /// Associates a password with the PDFDocument.
        /// Pass in numm or empty string to clear the password.
        /// </summary>
        /// <param name="pdf_document"></param>
        /// <param name="password"></param>
        public void AddPassword(PDFDocument pdf_document, string password)
        {
            if (null == pdf_document)
            {
                Logging.Warn("Can't associate a password with a null PDFDocument.");
            }

            if (String.IsNullOrEmpty(password))
            {
                RemovePassword(pdf_document);
            }
            else
            {
                ReversibleEncryption re = new ReversibleEncryption();
                Passwords[pdf_document.Fingerprint] = re.EncryptString(password);
                WritePasswordFile(Filename_Store, Passwords);
            }
        }