示例#1
0
 private bool LoadFile(string filename, PDFLibNet.PDFWrapper pdfDoc)
 {
     try
     {
         if (fs != null)
         {
             fs.Close();
             fs = null;
         }
         //Does not supported by MuPDF.                
         //fs = new System.IO.FileStream(filename, System.IO.FileMode.Open);                
         //return pdfDoc.LoadPDF(fs);                
         bool bRet =  pdfDoc.LoadPDF(filename);               
         tsbUseMuPDF.Checked = pdfDoc.UseMuPDF;
         return bRet;                
     }
     catch (System.Security.SecurityException)
     {
          frmPassword frm = new frmPassword();
          if (frm.ShowDialog() == DialogResult.OK)
          {
              if (!frm.UserPassword.Equals(String.Empty))
                  pdfDoc.UserPassword = frm.UserPassword;
              if (!frm.OwnerPassword.Equals(String.Empty))
                  pdfDoc.OwnerPassword = frm.OwnerPassword;
              return LoadFile(filename, pdfDoc);
          }
          else
          {
              MessageBox.Show(Resources.UIStrings.ErrorFileEncrypted ,Text);
              return false;
          }
     }
 }
示例#2
0
        private bool LoadFile(string filename, PDFLibNet.PDFWrapper pdfDoc)
        {
            try
            {
                if (fs != null)
                {
                    fs.Close();
                    fs = null;
                }
                fs = new System.IO.FileStream(filename, System.IO.FileMode.Open);
                return pdfDoc.LoadPDF(fs);

            }
            catch (System.Security.SecurityException)
            {    
                if (!_UserPassword.Equals(String.Empty))
                    pdfDoc.UserPassword =_UserPassword;
                if (!_OwnerPassword.Equals(String.Empty))
                    pdfDoc.OwnerPassword = _OwnerPassword;
                return LoadFile(filename, pdfDoc);
         
            }
        }