Browse Source

compdfkit(win) - 修复空签名相关问题

weixiangjie 1 năm trước cách đây
mục cha
commit
a177607e50

+ 17 - 0
Demo/Examples/Compdfkit_Tools/Common/Helper/CommonHelper.cs

@@ -7,6 +7,7 @@ using System.ComponentModel;
 using System.Diagnostics;
 using System.Drawing;
 using System.IO;
+using System.Linq;
 using System.Reflection;
 using System.Runtime.CompilerServices;
 using System.Text.RegularExpressions;
@@ -16,6 +17,7 @@ using System.Windows.Interop;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Xml;
+using ComPDFKit.DigitalSign;
 using Point = System.Windows.Point;
 using Size = System.Windows.Size;
 
@@ -1014,4 +1016,19 @@ namespace Compdfkit_Tools.Helper
             return standardZoom / 100;
         }
     }
+
+    public class SignatureHelper
+    {
+        public static List<CPDFSignature> GetEffectiveSignatureList(List<CPDFSignature>signatureList)
+        {
+            for(int index = signatureList.Count - 1; index >= 0; index--)
+            {
+                if (signatureList[index].SignerList.Count <= 0)
+                {
+                    signatureList.RemoveAt(index);
+                }
+            }
+            return signatureList;
+        }
+    }
 }

+ 2 - 1
Demo/Examples/Compdfkit_Tools/DigitalSignature/CPDFSignatureListControl/CPDFSignatureListControl.xaml.cs

@@ -8,6 +8,7 @@ using System.Windows.Controls;
 using System.Windows.Data;
 using System.Windows.Forms;
 using System.Windows.Input;
+using Compdfkit_Tools.Helper;
 using Compdfkit_Tools.PDFControl;
 using ComPDFKit.DigitalSign;
 using ComPDFKitViewer.PdfViewer;
@@ -107,7 +108,7 @@ namespace Compdfkit_Tools.DigitalSignature.CPDFSignatureListControl
         {
             if (pdfViewer != null && pdfViewer.Document != null)
             {
-                signatureList = pdfViewer.Document.GetSignatureList();
+                signatureList = SignatureHelper.GetEffectiveSignatureList(pdfViewer.Document.GetSignatureList());
                 if (signatureList != null)
                 {
                     SignatureList.ItemsSource = null;

+ 1 - 1
Demo/Examples/Compdfkit_Tools/DigitalSignature/DigitalSignatureControl/DigitalSignatureControl.xaml.cs

@@ -182,7 +182,7 @@ namespace Compdfkit_Tools.PDFControl
 
         private void RefreshDigitalSignatureList()
         {
-            signatureStatusBarControl.SetStatus(PDFViewControl.PDFView.Document.GetSignatureList());
+            signatureStatusBarControl.SetStatus(SignatureHelper.GetEffectiveSignatureList(PDFViewControl.PDFView.Document.GetSignatureList()));
         }
 
         private string GetTime()

+ 1 - 1
Demo/Examples/DigitalSignature/MainWindow.xaml.cs

@@ -169,7 +169,7 @@ namespace DigitalSignature
             regularViewerControl.SetDisplaySettingsControl(displaySettingsControl);
             PDFGrid.Child = regularViewerControl;
             
-            signatureStatusBarControl.SetStatus(pdfViewer.PDFView.Document.GetSignatureList());
+            signatureStatusBarControl.SetStatus(SignatureHelper.GetEffectiveSignatureList(pdfViewer.PDFView.Document.GetSignatureList()));
             regularViewerControl.SetSignatureStatusBarControl(signatureStatusBarControl);
 
             signatureStatusBarControl.OnViewSignatureButtonClicked -= ViewAllSignatures;