Browse Source

compdfkit(win) - 添加判断是否有权限方法

weixiangjie 1 year ago
parent
commit
c6efcb1892

+ 8 - 1
Demo/Examples/Compdfkit_Tools/Common/Helper/PasswordHelper.cs

@@ -65,7 +65,14 @@ namespace PasswordBoxPlus.Helper
                 window.Owner = Window.GetWindow(Application.Current.MainWindow);
                 window.Owner = Window.GetWindow(Application.Current.MainWindow);
             window.PasswordDialog.SetShowText(document.FileName + " " + LanguageHelper.CommonManager.GetString("Tip_Permission"));
             window.PasswordDialog.SetShowText(document.FileName + " " + LanguageHelper.CommonManager.GetString("Tip_Permission"));
             window.ShowDialog();
             window.ShowDialog();
-            return document.GetPermissionsInfo().AllowsCopying || document.GetPermissionsInfo().AllowsPrinting;
+            return !IsOwnerLocked(document);
+        }
+        
+        public static bool IsOwnerLocked(CPDFDocument document)
+        {
+            var info = document.GetPermissionsInfo();
+            return !info.AllowsCopying || !info.AllowsPrinting || !info.AllowsCommenting ||
+                   !info.AllowsHighQualityPrinting || !info.AllowsDocumentChanges || !info.AllowsDocumentAssembly;
         }
         }
     }
     }
 }
 }

+ 1 - 2
Demo/Examples/Compdfkit_Tools/Security/Encryption/FileGridListControl.xaml.cs

@@ -108,7 +108,7 @@ namespace Compdfkit_Tools.PDFControl
                     continue;
                     continue;
                 }
                 }
                 
                 
-                if (document.GetPermissionsInfo().AllowsCopying || document.GetPermissionsInfo().AllowsPrinting)
+                if (PasswordHelper.IsOwnerLocked(document))
                 {
                 {
                     if(!PasswordHelper.UnlockWithOwnerPassword(document))
                     if(!PasswordHelper.UnlockWithOwnerPassword(document))
                     {
                     {
@@ -119,7 +119,6 @@ namespace Compdfkit_Tools.PDFControl
                 
                 
                 fileInfoData.Document = document;
                 fileInfoData.Document = document;
                 FileInfoDataList.Add(fileInfoData);
                 FileInfoDataList.Add(fileInfoData);
-
             }
             }
         }
         }