|
@@ -1992,43 +1992,45 @@ namespace PDF_Office.ViewModels
|
|
|
{
|
|
|
string currentPath = PDFViewer.Document.FilePath;
|
|
|
string tempPath = PDFViewer.Document.FilePath + ".temp.pdf";
|
|
|
- PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
|
|
|
-
|
|
|
- PDFViewer.Document.WriteToFilePath(tempPath);
|
|
|
- PDFViewer.CloseDocument();
|
|
|
- PDFViewer.InitDocument(tempPath);
|
|
|
- if (!string.IsNullOrEmpty(permissionsPassword))
|
|
|
+ if (PDFViewer.Document.Descrypt(tempPath))
|
|
|
{
|
|
|
- PDFViewer.Document.UnlockWithPassword(permissionsPassword);
|
|
|
+ PDFViewer.CloseDocument();
|
|
|
+ PDFViewer.InitDocument(tempPath);
|
|
|
+ PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
|
|
|
+ if (PDFViewer.Document.WriteToFilePath(currentPath))
|
|
|
+ {
|
|
|
+ PDFViewer.CloseDocument();
|
|
|
+ PDFViewer.InitDocument(currentPath);
|
|
|
+ if (!string.IsNullOrEmpty(openPassword))
|
|
|
+ {
|
|
|
+ PDFViewer.Document.UnlockWithPassword(openPassword);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(permissionsPassword))
|
|
|
+ {
|
|
|
+ PDFViewer.Document.CheckOwnerPassword(permissionsPassword);
|
|
|
+ }
|
|
|
+ try
|
|
|
+ {
|
|
|
+ PDFViewer.Load();
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ }
|
|
|
+ PDFViewer.UndoManager.CanSave = false;
|
|
|
+ SecurityInfo.IsPasswordChanged = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ System.IO.File.Delete(tempPath);
|
|
|
}
|
|
|
- else if (!string.IsNullOrEmpty(openPassword))
|
|
|
+ else
|
|
|
{
|
|
|
- PDFViewer.Document.UnlockWithPassword(openPassword);
|
|
|
+ return false;
|
|
|
}
|
|
|
- PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
|
|
|
-
|
|
|
- PDFViewer.Document.WriteToFilePath(currentPath);
|
|
|
- PDFViewer.CloseDocument();
|
|
|
- PDFViewer.InitDocument(currentPath);
|
|
|
- System.IO.File.Delete(tempPath);
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(permissionsPassword))
|
|
|
- {
|
|
|
- PDFViewer.Document.UnlockWithPassword(permissionsPassword);
|
|
|
- }
|
|
|
- else if (!string.IsNullOrEmpty(openPassword))
|
|
|
- {
|
|
|
- PDFViewer.Document.UnlockWithPassword(openPassword);
|
|
|
- }
|
|
|
- try
|
|
|
- {
|
|
|
- PDFViewer.Load();
|
|
|
- }
|
|
|
- catch
|
|
|
- {
|
|
|
- }
|
|
|
- PDFViewer.UndoManager.CanSave = false;
|
|
|
- SecurityInfo.IsPasswordChanged = false;
|
|
|
return true;
|
|
|
}
|
|
|
catch
|
|
@@ -2120,6 +2122,10 @@ namespace PDF_Office.ViewModels
|
|
|
return result;
|
|
|
}
|
|
|
catch { return false; }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ ShowLeftTip(false);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -2145,6 +2151,7 @@ namespace PDF_Office.ViewModels
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+
|
|
|
result = PDFViewer.Document.WriteToFilePath(dlg.FileName);
|
|
|
if (result)
|
|
|
{
|