소스 검색

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

weixiangjie 1 년 전
부모
커밋
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.PasswordDialog.SetShowText(document.FileName + " " + LanguageHelper.CommonManager.GetString("Tip_Permission"));
             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;
                 }
                 
-                if (document.GetPermissionsInfo().AllowsCopying || document.GetPermissionsInfo().AllowsPrinting)
+                if (PasswordHelper.IsOwnerLocked(document))
                 {
                     if(!PasswordHelper.UnlockWithOwnerPassword(document))
                     {
@@ -119,7 +119,6 @@ namespace Compdfkit_Tools.PDFControl
                 
                 fileInfoData.Document = document;
                 FileInfoDataList.Add(fileInfoData);
-
             }
         }