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)); } }
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); bool bRet = pdfDoc.LoadPDF(filename); 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); } } }