Browse Source

compdfkit(win)

liuaoran 1 year ago
parent
commit
35e0add9b2
41 changed files with 67055 additions and 194 deletions
  1. 1 1
      Demo/Examples/AnnotationViewControl/MainWindow.xaml.cs
  2. 41 36
      Demo/Examples/Compdfkit_Tools/Common/Helper/CommonHelper.cs
  3. 24 8
      Demo/Examples/Compdfkit_Tools/Compdfkit_Tools.csproj
  4. 1 7
      Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddCertificationControl.xaml.cs
  5. 1 2
      Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddCertificationDialog.xaml
  6. 26 17
      Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddCertificationDialog.xaml.cs
  7. 20 17
      Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddCustomCertificationControl.xaml
  8. 134 1
      Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddCustomCertificationControl.xaml.cs
  9. 2 3
      Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddExistedCertificationControl.xaml
  10. 48 0
      Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/SaveCerficateControl.xaml
  11. 92 0
      Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/SaveCerficateControl.xaml.cs
  12. 0 40
      Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/SaveCustomCertificationControl.xaml.cs
  13. 45 0
      Demo/Examples/Compdfkit_Tools/DigitalSignature/DigitalSignatureData/DigitalSignatureData.cs
  14. 9 24
      Demo/Examples/Compdfkit_Tools/DigitalSignature/FillDigitalSignatureControl/FillDigitalSignatureControl.xaml
  15. 97 25
      Demo/Examples/Compdfkit_Tools/DigitalSignature/FillDigitalSignatureControl/FillDigitalSignatureControl.xaml.cs
  16. 13 0
      Demo/Examples/Compdfkit_Tools/DigitalSignature/FillDigitalSignatureControl/FillDigitalSignatureDialog.xaml
  17. 38 0
      Demo/Examples/Compdfkit_Tools/DigitalSignature/FillDigitalSignatureControl/FillDigitalSignatureDialog.xaml.cs
  18. 1 1
      Demo/Examples/Compdfkit_Tools/PageEdit/PDFPageInsert/CPDFPageInsertUI.xaml.cs
  19. 1 0
      Demo/Examples/Compdfkit_Tools/packages.config
  20. 1 1
      Demo/Examples/ContentEditorViewControl/MainWindow.xaml.cs
  21. 8 6
      Demo/Examples/DigitalSignature/DigitalSignature.csproj
  22. 1 1
      Demo/Examples/DigitalSignature/MainWindow.xaml.cs
  23. 1 1
      Demo/Examples/FormViewControl/MainWindow.xaml.cs
  24. 1 1
      Demo/Examples/PDFViewer/MainPage.xaml.cs
  25. 1 1
      Demo/Examples/PDFViewer/MainWindow.xaml.cs
  26. 1 1
      Demo/Examples/Viewer/MainWindow.xaml.cs
  27. BIN
      Demo/Examples/packages/ComPDFKit.NetFramework.1.9.1/build/x64/ComPDFKit.dll
  28. BIN
      Demo/Examples/packages/Nager.Country.4.0.0/.signature.p7s
  29. 21 0
      Demo/Examples/packages/Nager.Country.4.0.0/LICENSE.md
  30. BIN
      Demo/Examples/packages/Nager.Country.4.0.0/Nager.Country.4.0.0.nupkg
  31. 29 0
      Demo/Examples/packages/Nager.Country.4.0.0/README.md
  32. BIN
      Demo/Examples/packages/Nager.Country.4.0.0/icon.png
  33. BIN
      Demo/Examples/packages/Nager.Country.4.0.0/lib/net48/Nager.Country.dll
  34. 16588 0
      Demo/Examples/packages/Nager.Country.4.0.0/lib/net48/Nager.Country.xml
  35. BIN
      Demo/Examples/packages/Nager.Country.4.0.0/lib/net6.0/Nager.Country.dll
  36. 16588 0
      Demo/Examples/packages/Nager.Country.4.0.0/lib/net6.0/Nager.Country.xml
  37. BIN
      Demo/Examples/packages/Nager.Country.4.0.0/lib/netstandard2.0/Nager.Country.dll
  38. 16588 0
      Demo/Examples/packages/Nager.Country.4.0.0/lib/netstandard2.0/Nager.Country.xml
  39. BIN
      Demo/Examples/packages/Nager.Country.4.0.0/lib/netstandard2.1/Nager.Country.dll
  40. 16588 0
      Demo/Examples/packages/Nager.Country.4.0.0/lib/netstandard2.1/Nager.Country.xml
  41. 45 0
      Demo/Examples/packages/Nager.Country.4.0.0/readme.txt

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

@@ -185,7 +185,7 @@ namespace AnnotationViewControl
         
         private void OpenFile()
         {
-            string filePath = CommonHelper.GetFilePathOrEmpty();
+            string filePath = CommonHelper.GetExistedPathOrEmpty();
             if (!string.IsNullOrEmpty(filePath) && annotationControl.PdfViewControl != null)
             {
                 if (pdfViewer.PDFView != null && pdfViewer.PDFView.Document != null)

+ 41 - 36
Demo/Examples/Compdfkit_Tools/Common/Helper/CommonHelper.cs

@@ -9,6 +9,7 @@ using System.Drawing;
 using System.IO;
 using System.Reflection;
 using System.Runtime.CompilerServices;
+using System.Text.RegularExpressions;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Media;
@@ -47,6 +48,15 @@ namespace Compdfkit_Tools.Helper
 
     public static class CommonHelper
     {
+        public static string EmailPattern = @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$";
+
+
+        public static bool IsValidEmail(string email)
+        {
+            string emailPattern = @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$";
+            return Regex.IsMatch(email, emailPattern);
+        }
+
         /// <summary>
         /// Returns the file size based on the specified file path, with the smallest unit being bytes (B).
         /// </summary>
@@ -56,52 +66,33 @@ namespace Compdfkit_Tools.Helper
         /// </returns>
         public static string GetFileSize(string filePath)
         {
-            FileInfo fileInfo = null;
             try
             {
-                fileInfo = new FileInfo(filePath);
+                long fileSize = new FileInfo(filePath).Length;
+                string[] sizes = { "B", "KB", "MB", "GB" };
+                int order = 0;
+
+                while (fileSize >= 1024 && order < sizes.Length - 1)
+                {
+                    fileSize /= 1024;
+                    order++;
+                }
+
+                return $"{fileSize} {sizes[order]}";
             }
             catch
             {
                 return "0B";
             }
-            if (fileInfo != null && fileInfo.Exists)
-            {
-                double fileSize = fileInfo.Length;
-                if (fileSize > 1024)
-                {
-                    fileSize = Math.Round(fileSize / 1024, 2);
-                    if (fileSize > 1024)
-                    {
-                        fileSize = Math.Round(fileSize / 1024, 2);
-                        if (fileSize > 1024)
-                        {
-                            fileSize = Math.Round(fileSize / 1024, 2);
-                            return fileSize + " GB";
-                        }
-                        else
-                        {
-                            return fileSize + " MB";
-                        }
-                    }
-                    else
-                    {
-                        return fileSize + " KB";
-                    }
-                }
-                else
-                {
-                    return fileSize + " B";
-                }
-            }
-            return "0B";
         }
          
-        public static string GetFilePathOrEmpty()
+        public static string GetExistedPathOrEmpty()
         {
             string selectedFilePath = string.Empty;
-            OpenFileDialog openFileDialog = new OpenFileDialog();
-            openFileDialog.Filter = "PDF files (*.pdf)|*.pdf";
+            OpenFileDialog openFileDialog = new OpenFileDialog
+            {
+                Filter = "PDF files (*.pdf)|*.pdf"
+            };
 
             if (openFileDialog.ShowDialog() == true)
             {
@@ -109,7 +100,21 @@ namespace Compdfkit_Tools.Helper
             }
             return selectedFilePath;
         }
-         
+          
+        public static string GetGeneratePathOrEmpty(string filter)
+        {
+            string selectedFilePath = string.Empty;
+            SaveFileDialog saveFileDialog = new SaveFileDialog
+            {
+                Filter = filter
+            };
+            if (saveFileDialog.ShowDialog() == true)
+            {
+                selectedFilePath = saveFileDialog.FileName;
+            }
+            return selectedFilePath;
+        }
+
         public static bool GetPagesInRange(ref List<int> pageList, string pageRange, int count, char[] enumerationSeparator, char[] rangeSeparator, bool inittag = false)
         {
             string[] rangeSplit = pageRange.Split(enumerationSeparator); 

+ 24 - 8
Demo/Examples/Compdfkit_Tools/Compdfkit_Tools.csproj

@@ -44,11 +44,8 @@
     <ApplicationIcon>ComPDFKit_Logo.ico</ApplicationIcon>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="ComPDFKit.Desk, Version=1.9.1.0, Culture=neutral, processorArchitecture=MSIL">
-      <HintPath>..\packages\ComPDFKit.NetFramework.1.9.1\lib\ComPDFKit.Desk.dll</HintPath>
-    </Reference>
-    <Reference Include="ComPDFKit.Viewer, Version=1.9.1.0, Culture=neutral, processorArchitecture=MSIL">
-      <HintPath>..\packages\ComPDFKit.NetFramework.1.9.1\lib\ComPDFKit.Viewer.dll</HintPath>
+    <Reference Include="Nager.Country, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\Nager.Country.4.0.0\lib\netstandard2.0\Nager.Country.dll</HintPath>
     </Reference>
     <Reference Include="PresentationFramework.Aero2, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
       <HintPath>..\packages\PresentationFramework.Aero2.1.0.1\lib\PresentationFramework.Aero2.dll</HintPath>
@@ -219,12 +216,16 @@
     <Compile Include="DigitalSignature\AddCertificationControl\AddExistedCertificationControl.xaml.cs">
       <DependentUpon>AddExistedCertificationControl.xaml</DependentUpon>
     </Compile>
-    <Compile Include="DigitalSignature\AddCertificationControl\SaveCustomCertificationControl.xaml.cs">
-      <DependentUpon>SaveCustomCertificationControl.xaml</DependentUpon>
+    <Compile Include="DigitalSignature\AddCertificationControl\SaveCerficateControl.xaml.cs">
+      <DependentUpon>SaveCerficateControl.xaml</DependentUpon>
     </Compile>
     <Compile Include="DigitalSignature\DigitalSignatureControl\DigitalSignatureControl.xaml.cs">
       <DependentUpon>DigitalSignatureControl.xaml</DependentUpon>
     </Compile>
+    <Compile Include="DigitalSignature\FillDigitalSignatureControl\FillDigitalSignatureDialog.xaml.cs">
+      <DependentUpon>FillDigitalSignatureDialog.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="DigitalSignature\DigitalSignatureData\DigitalSignatureData.cs" />
     <Compile Include="DigitalSignature\FillDigitalSignatureControl\FillDigitalSignatureControl.xaml.cs">
       <DependentUpon>FillDigitalSignatureControl.xaml</DependentUpon>
     </Compile>
@@ -690,11 +691,18 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="DigitalSignature\AddCertificationControl\SaveCustomCertificationControl.xaml" />
+    <Page Include="DigitalSignature\AddCertificationControl\SaveCerficateControl.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="DigitalSignature\DigitalSignatureControl\DigitalSignatureControl.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="DigitalSignature\FillDigitalSignatureControl\FillDigitalSignatureDialog.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="DigitalSignature\FillDigitalSignatureControl\FillDigitalSignatureControl.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
@@ -919,6 +927,14 @@
       <Project>{56e518ad-c126-4b48-9a09-0a64c87020e4}</Project>
       <Name>ComPDFKit.Desk</Name>
     </ProjectReference>
+    <ProjectReference Include="..\..\..\..\compdfkit\ComPDFKit\ComPDFKitCSharp\ComPDFKit.Desk.csproj">
+      <Project>{56e518ad-c126-4b48-9a09-0a64c87020e4}</Project>
+      <Name>ComPDFKit.Desk</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\..\compdfkit\ComPDFKit\ComPDFKitDesktop\ComPDFKit.Viewer\ComPDFKit.Viewer.csproj">
+      <Project>{18ec356d-8130-49d4-b4e6-ac290e1065b7}</Project>
+      <Name>ComPDFKit.Viewer</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\..\..\compdfkit\ComPDFKit\ComPDFKitDesktop\ComPDFKit.Viewer\ComPDFKit.Viewer.csproj">
       <Project>{18ec356d-8130-49d4-b4e6-ac290e1065b7}</Project>
       <Name>ComPDFKit.Viewer</Name>

+ 1 - 7
Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddCertificationControl.xaml.cs

@@ -6,13 +6,7 @@ using System.Windows;
 using System.Windows.Controls;
 
 namespace Compdfkit_Tools.PDFControl
-{
-    public enum CreateCertificationMode
-    {
-        AddExistedCertification,
-        AddCustomCertification
-    }
-
+{ 
     public partial class AddCertificationControl : UserControl, INotifyPropertyChanged
     {
         public Dictionary<bool, CreateCertificationMode> getCreateCertificationMode = new Dictionary<bool, CreateCertificationMode>()

+ 1 - 2
Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddCertificationDialog.xaml

@@ -7,8 +7,7 @@
         mc:Ignorable="d"
         ResizeMode="NoResize"
         Title="AddCertificationDialog" Height="505" Width="482"
-        Loaded="Window_Loaded"
-        Unloaded="Window_Unloaded">
+        Loaded="Window_Loaded">
     <Border x:Name="BodyBd">
         
     </Border>

+ 26 - 17
Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddCertificationDialog.xaml.cs

@@ -21,6 +21,8 @@ namespace Compdfkit_Tools.PDFControl
     {
         private AddCertificationControl addCertificationControl = null;
         private AddCustomCertificationControl addCustomCertificationControl = null;
+        private AddExistedCertificationControl addExistedCertificationControl = null;
+        private SaveCerficateControl saveCerficateControl = null;
 
         public AddCertificationDialog()
         {
@@ -31,38 +33,45 @@ namespace Compdfkit_Tools.PDFControl
 
         private void Window_Loaded(object sender, RoutedEventArgs e)
         {
-            addCertificationControl.ContinueEvent += ContinueEvent ;
+            addCertificationControl.ContinueEvent -= ContinueEvent;
+            addCertificationControl.ContinueEvent += ContinueEvent;
         }
 
         private void ContinueEvent(object sender, CreateCertificationMode e)
         {
             if(e == CreateCertificationMode.AddExistedCertification)
+            {
+                addExistedCertificationControl = new AddExistedCertificationControl();
+                BodyBd.Child = addExistedCertificationControl;
+                this.Height = addExistedCertificationControl.Height + 35;
+                this.Width = addExistedCertificationControl.Width + 20;
+                 
+                addExistedCertificationControl.CancelEvent += CancelEvent;
+                
+            }
+            else if(e == CreateCertificationMode.AddCustomCertification)
             {
                 addCustomCertificationControl = new AddCustomCertificationControl();
-
                 BodyBd.Child = addCustomCertificationControl;
                 this.Height = addCustomCertificationControl.Height + 35;
                 this.Width = addCustomCertificationControl.Width + 20;
 
+                addCustomCertificationControl.ContinueEvent -= ContinueEvent;
+                addCustomCertificationControl.ContinueEvent += ContinueEvent;
+
+                addCustomCertificationControl.CancelEvent -= CancelEvent;
                 addCustomCertificationControl.CancelEvent += CancelEvent;
-                addCertificationControl.ContinueEvent -= ContinueEvent;
             }
-            else
+            else if (e == CreateCertificationMode.SaveCertificate)
             {
-                AddExistedCertificationControl addExistedCertificationControl = new AddExistedCertificationControl();
-                BodyBd.Child = addExistedCertificationControl;
-                this.Height = addExistedCertificationControl.Height + 35;
-                this.Width = addExistedCertificationControl.Width + 20;
-                addExistedCertificationControl.CancelEvent += CancelEvent;
-                addCertificationControl.ContinueEvent -= ContinueEvent; 
+                saveCerficateControl = new SaveCerficateControl();
+                saveCerficateControl.CertificateInfo = addCustomCertificationControl.certificateInfo;
+                BodyBd.Child = saveCerficateControl;
+                this.Height = saveCerficateControl.Height + 20;
+                this.Width = saveCerficateControl.Width + 20;
             }
         }
-
-
-        private void Window_Unloaded(object sender, RoutedEventArgs e)
-        {
-            addCertificationControl.ContinueEvent += ContinueEvent;
-        }
+        
 
         private void CancelEvent(object sender, EventArgs e)
         {
@@ -70,7 +79,7 @@ namespace Compdfkit_Tools.PDFControl
             BodyBd.Child = addCertificationControl;
             this.Height = addCertificationControl.Height + 35;
             this.Width = addCertificationControl.Width + 20;
-            addCustomCertificationControl.CancelEvent -= CancelEvent;
+            addCertificationControl.ContinueEvent -= ContinueEvent;
             addCertificationControl.ContinueEvent += ContinueEvent;
         }
     }

+ 20 - 17
Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddCustomCertificationControl.xaml

@@ -28,6 +28,7 @@
                     <RowDefinition></RowDefinition>
                     <RowDefinition></RowDefinition>
                     <RowDefinition></RowDefinition>
+                    <RowDefinition></RowDefinition>
                 </Grid.RowDefinitions>
                 <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="*"></ColumnDefinition>
@@ -35,33 +36,35 @@
                 </Grid.ColumnDefinitions>
                 <TextBlock Text="Grantor Name" VerticalAlignment="Center"></TextBlock>
                 <Grid Grid.Column="1">
-                    <TextBox Height="28" x:Name="GrantorNameTxt" VerticalContentAlignment="Center" VerticalAlignment="Center"/>
-                    <TextBlock Text="Please Enter Grantor Name" VerticalAlignment="Center"  Margin="10" Visibility="{Binding ElementName=GrantorNameTxt, Path=Text, Converter={StaticResource TextLengthToVisibilityConverter}}" IsHitTestVisible="False"  Foreground="#BBB"></TextBlock>
+                    <TextBox Height="28" x:Name="GrantorNameTxt" VerticalContentAlignment="Center" VerticalAlignment="Center" Text="{Binding GrantorName}"/>
+                    <TextBlock Text="Please Enter Grantor Name" VerticalAlignment="Center"  Margin="10,0,0,0" Visibility="{Binding ElementName=GrantorNameTxt, Path=Text, Converter={StaticResource TextLengthToVisibilityConverter}}" IsHitTestVisible="False"  Foreground="#BBB"></TextBlock>
                 </Grid>
-                <TextBlock Grid.Row="1" Text="Parse2Txt" VerticalAlignment="Center"></TextBlock>
+                <TextBlock Grid.Row="1" Text="Organizational Unit" VerticalAlignment="Center"></TextBlock>
                 <Grid Grid.Column="1" Grid.Row="1">
-                    <TextBox Height="28" x:Name="Parse2Txt" VerticalContentAlignment="Center" VerticalAlignment="Center"/>
-                    <TextBlock Text="Please Enter Parse2Txt" VerticalAlignment="Center"  Margin="10" Visibility="{Binding ElementName=Parse2Txt, Path=Text, Converter={StaticResource TextLengthToVisibilityConverter}}" IsHitTestVisible="False"  Foreground="#BBB"></TextBlock>
+                    <TextBox Height="28" x:Name="OrganizationalUnitTxt" VerticalContentAlignment="Center" Text="{Binding OrganizationalUnit}" VerticalAlignment="Center"/>
+                    <TextBlock Text="Please Enter Organizational Unit" VerticalAlignment="Center"  Margin="10,0,0,0" Visibility="{Binding ElementName=OrganizationalUnitTxt, Path=Text, Converter={StaticResource TextLengthToVisibilityConverter}}" IsHitTestVisible="False"  Foreground="#BBB"></TextBlock>
                 </Grid>
-                <TextBlock Grid.Row="2" Text="Departmental" VerticalAlignment="Center"></TextBlock>
+                <TextBlock Grid.Row="2" Text="Organization" VerticalAlignment="Center"></TextBlock>
                 <Grid Grid.Column="1" Grid.Row="2">
-                    <TextBox Height="28" x:Name="DepartmentalTxt" VerticalContentAlignment="Center" VerticalAlignment="Center"/>
-                    <TextBlock Text="Please Enter Departmental" VerticalAlignment="Center"  Margin="10" Visibility="{Binding ElementName=DepartmentalTxt, Path=Text, Converter={StaticResource TextLengthToVisibilityConverter}}" IsHitTestVisible="False"  Foreground="#BBB"></TextBlock>
+                    <TextBox Height="28" x:Name="OrganizationTxt" VerticalContentAlignment="Center" Text="{Binding Organization}" VerticalAlignment="Center"/>
+                    <TextBlock Text="Please Enter Organization" VerticalAlignment="Center"  Margin="10,0,0,0" Visibility="{Binding ElementName=OrganizationTxt, Path=Text, Converter={StaticResource TextLengthToVisibilityConverter}}" IsHitTestVisible="False"  Foreground="#BBB"></TextBlock>
                 </Grid>
-                <TextBlock Grid.Row="3" Text="Unit Name" VerticalAlignment="Center"></TextBlock>
+                <TextBlock Grid.Row="3" Text="Email" VerticalAlignment="Center"></TextBlock>
                 <Grid Grid.Column="1" Grid.Row="3">
-                    <TextBox Height="28" x:Name="UnitNameTxt" VerticalContentAlignment="Center" VerticalAlignment="Center"/>
-                    <TextBlock Text="Please Enter Unit Name" VerticalAlignment="Center"  Margin="10" Visibility="{Binding ElementName=UnitNameTxt, Path=Text, Converter={StaticResource TextLengthToVisibilityConverter}}" IsHitTestVisible="False"  Foreground="#BBB"></TextBlock>
+                    <TextBox Height="28" x:Name="EmailTxt" VerticalContentAlignment="Center" Text="{Binding Email}" VerticalAlignment="Center"/>
+                    <TextBlock Text="Please Enter Email" VerticalAlignment="Center"  Margin="10,0,0,0" Visibility="{Binding ElementName=EmailTxt, Path=Text, Converter={StaticResource TextLengthToVisibilityConverter}}" IsHitTestVisible="False"  Foreground="#BBB"></TextBlock>
                 </Grid>
-                <TextBlock Grid.Row="4" Text="Email" VerticalAlignment="Center"></TextBlock>
+                <TextBlock Grid.Row="4" Text="Country/Area" VerticalAlignment="Center"></TextBlock>
                 <Grid Grid.Column="1" Grid.Row="4">
-                    <TextBox Height="28" x:Name="EmailTxt" VerticalContentAlignment="Center" VerticalAlignment="Center"/>
-                    <TextBlock Text="Please Enter Email" VerticalAlignment="Center"  Margin="10" Visibility="{Binding ElementName=EmailTxt, Path=Text, Converter={StaticResource TextLengthToVisibilityConverter}}" IsHitTestVisible="False"  Foreground="#BBB"></TextBlock>
+                    <ComboBox Margin="0,5,0,5" Name="AreaCmb" SelectedIndex="0" SelectionChanged="AreaCmb_SelectionChanged"></ComboBox>
                 </Grid>
-                <TextBlock Grid.Row="5" Text="Country/Area" VerticalAlignment="Center"></TextBlock>
+                <TextBlock Grid.Row="5" Text="Algorithm" VerticalAlignment="Center"></TextBlock>
                 <Grid Grid.Column="1" Grid.Row="5">
-                    <TextBox Height="28" x:Name="AreaTxt" VerticalContentAlignment="Center" VerticalAlignment="Center"/>
-                    <ComboBox Margin="0,5,0,5"></ComboBox>
+                    <ComboBox Margin="0,5,0,5" Name="AlgorithmCmb" SelectedIndex="0" SelectionChanged="AlgorithmCmb_SelectionChanged"></ComboBox>
+                </Grid>
+                <TextBlock Grid.Row="6" Text="Purpose" VerticalAlignment="Center"></TextBlock>
+                <Grid Grid.Column="1" Grid.Row="6">
+                    <ComboBox Margin="0,5,0,5" Name="PurposeCmb" SelectedIndex="0" SelectionChanged="PurposeCmb_SelectionChanged"></ComboBox>
                 </Grid>
             </Grid>
         </Border>

+ 134 - 1
Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddCustomCertificationControl.xaml.cs

@@ -1,5 +1,7 @@
 using ComPDFKit.PDFAnnotation;
 using ComPDFKit.PDFDocument;
+using Compdfkit_Tools.Helper;
+using Nager.Country;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -17,6 +19,8 @@ using System.Windows.Shapes;
 
 namespace Compdfkit_Tools.PDFControl
 {
+
+
     /// <summary>
     /// AddCustomCertificationControl.xaml 的交互逻辑
     /// </summary>
@@ -24,9 +28,98 @@ namespace Compdfkit_Tools.PDFControl
     {
         public event EventHandler SaveEvent;
         public event EventHandler CancelEvent;
+        public CertificateInfo certificateInfo = new CertificateInfo();
+
+        private string _grantorName = string.Empty;
+        public string GrantorName
+        {
+            get => _grantorName;
+            set
+            {
+                _grantorName = value;
+                certificateInfo.GrantorName = value;
+            }
+        }
+
+        private string _email = string.Empty;
+        public string Email
+        {
+            get => _email;
+            set
+            {
+                _email = value;
+                certificateInfo.Email = value;
+            }
+        }
+
+        private string _organization = string.Empty;
+        public string Organization
+        {
+            get => _organization;
+            set
+            {
+                _organization = value;
+                certificateInfo.Organization = value;
+            }
+        }
+
+        private string _organizationalUnit = string.Empty;
+        public string OrganizationalUnit
+        {
+            get => _organizationalUnit;
+            set
+            {
+                _organizationalUnit = value;
+                certificateInfo.OrganizationUnit = value;
+            }
+        }
+
+        private readonly CountryProvider countryProvider = new CountryProvider();
+        private readonly List<string> countryNames = new List<string>();
+        
+        public event EventHandler<CreateCertificationMode> ContinueEvent;
+
         public AddCustomCertificationControl()
         {
             InitializeComponent();
+            this.DataContext = this;
+            FillComboBox();
+        }
+
+        private void FillComboBox()
+        {
+            FillComboBoxWithCountries();
+            FillComboBoxWithAlgorithm();
+            FillComboBoxWithPropose();
+        }
+
+        private void FillComboBoxWithPropose()
+        {
+            PurposeCmb.Items.Clear();
+            PurposeCmb.Items.Add("Digital Signatures");
+            PurposeCmb.Items.Add("Data Encryption");
+            PurposeCmb.Items.Add("Digital Signatures and Data Encryption");
+
+        }
+
+        private void FillComboBoxWithAlgorithm()
+        {
+            AlgorithmCmb.Items.Clear();
+            AlgorithmCmb.Items.Add("1024-bit RSA");
+            AlgorithmCmb.Items.Add("2048-bit RSA");
+        }
+
+        private void FillComboBoxWithCountries()
+        {
+            AlgorithmCmb.Items.Clear();
+            var countries = countryProvider.GetCountries();
+            foreach (var country in countries)
+            {
+                var formattedName = $"{country.Alpha2Code} - {country.CommonName}";
+                countryNames.Add(formattedName);
+            }
+
+            AreaCmb.ItemsSource = countryNames;
         }
 
         private void CancelBtn_Click(object sender, RoutedEventArgs e)
@@ -36,7 +129,47 @@ namespace Compdfkit_Tools.PDFControl
 
         private void SaveBtn_Click(object sender, RoutedEventArgs e)
         {
-            
+
+            if (certificateInfo.GrantorName == string.Empty)
+            {
+                return;
+            }
+            else if(certificateInfo.Email == string.Empty)
+            {
+                return;
+            }
+            else if (!CommonHelper.IsValidEmail(certificateInfo.Email))
+            {
+                return;
+            }
+            ContinueEvent?.Invoke(this, CreateCertificationMode.SaveCertificate);
+
+        }
+
+        private void AreaCmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            if (AreaCmb.SelectedItem != null)
+            {
+                string selectedText = AreaCmb.SelectedItem.ToString();
+                string[] parts = selectedText.Split('-');
+                certificateInfo.Area = parts[0].Trim(); // Extract the Alpha2Code 
+            }
+        }
+
+        private void AlgorithmCmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            if (AlgorithmCmb.SelectedItem != null)
+            {
+                certificateInfo.AlgorithmType = (AlgorithmType)AlgorithmCmb.SelectedIndex;
+            }
+        }
+
+        private void PurposeCmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            if (PurposeCmb.SelectedItem != null)
+            {
+                certificateInfo.PurposeType = (PurposeType)PurposeCmb.SelectedIndex;
+            }
         }
     }
 }

+ 2 - 3
Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/AddExistedCertificationControl.xaml

@@ -9,7 +9,7 @@
         Height="277" Width="470">
     <UserControl.Resources>
         <common:TextLengthToVisibilityConverter x:Key="TextLengthToVisibilityConverter"></common:TextLengthToVisibilityConverter>
-        </UserControl.Resources>
+    </UserControl.Resources>
     <Grid>
         <Grid.RowDefinitions>
             <RowDefinition Height="auto"></RowDefinition>
@@ -40,7 +40,6 @@
                 <Button x:Name="CancelBtn" Content="Cancel"  Margin="0,0,10,0" Width="112" Height="32" BorderThickness="1" Click="CancelBtn_Click"></Button>
                 <Button x:Name="DoneBtn" Content="Done" Width="112" Height="32" BorderThickness="1" Click="DoneBtn_Click"></Button>
             </StackPanel>
-        </Grid>
-
+        </Grid> 
     </Grid>
 </UserControl>

+ 48 - 0
Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/SaveCerficateControl.xaml

@@ -0,0 +1,48 @@
+<UserControl x:Class="Compdfkit_Tools.PDFControl.SaveCerficateControl"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:Compdfkit_Tools.PDFControl"
+             xmlns:common="clr-namespace:Compdfkit_Tools.Common"
+             mc:Ignorable="d"
+             Height="310" Width="550">
+    <UserControl.Resources>
+        <common:TextLengthToVisibilityConverter x:Key="TextLengthToVisibilityConverter"></common:TextLengthToVisibilityConverter>
+    </UserControl.Resources>
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="auto"></RowDefinition>
+            <RowDefinition Height="auto"></RowDefinition>
+            <RowDefinition Height="auto"></RowDefinition>
+            <RowDefinition Height="auto"></RowDefinition>
+            <RowDefinition></RowDefinition>
+        </Grid.RowDefinitions>
+        <TextBlock TextWrapping="Wrap" FontSize="14" Foreground="#000000" Margin="10,20,10,20" Height="40"
+                   Text="Browse digital ID files. Digital ID files are password protected. If you do not know its password, you cannot access the digital ID card.">
+        </TextBlock>
+        <StackPanel Grid.Row="1" Orientation="Horizontal" Margin="10,0,0,8">
+            <TextBlock Text="Files" Foreground="#43474D" FontSize="14" VerticalAlignment="Center" Margin="10,0,10,0" HorizontalAlignment="Left" Width="120" FontFamily="Segoe UI"></TextBlock>
+            <Grid>
+                <TextBox Width="258" Height="28"  x:Name="FileNameText" VerticalContentAlignment="Center" VerticalAlignment="Center" IsReadOnly="True" Text="{Binding FilePath, Mode =TwoWay}"/>
+                <TextBlock Text="Select a file" Margin="8" VerticalAlignment="Center"   Visibility="{Binding ElementName=FileNameText, Path=Text, Converter={StaticResource TextLengthToVisibilityConverter}}" IsHitTestVisible="False"  Foreground="#BBB"></TextBlock>
+            </Grid>
+            <Button x:Name="SelectFileBtn" Content="Select File" Width="90" Height="28" FontSize="14" FontFamily="Segoe UI" Margin="8,0,0,0" Click="SelectFileBtn_Click"></Button>
+        </StackPanel>
+        <StackPanel Grid.Row="2" Orientation="Horizontal"  Margin="10,0,0,8">
+            <TextBlock Foreground="#43474D" Width="120" FontSize="14" FontFamily="Segoe UI" Text="Set Password" VerticalAlignment="Top" Margin="10,5,10,0"></TextBlock>
+            <PasswordBox Name="SetPasswordPbx" Padding="5,0,0,0" Width="258" Height="28"  VerticalContentAlignment="Center" VerticalAlignment="Center"></PasswordBox>
+        </StackPanel>
+        <StackPanel Grid.Row="3" Orientation="Horizontal"  Margin="10,0,0,8">
+            <TextBlock Foreground="#43474D" Width="120" FontSize="14" FontFamily="Segoe UI" Text="Confirm Password" VerticalAlignment="Top" Margin="10,5,10,0"></TextBlock>
+            <PasswordBox Name="ConfirmPasswordPbx" Padding="5,0,0,0" Width="258" Height="28"  VerticalContentAlignment="Center" VerticalAlignment="Center"></PasswordBox>
+        </StackPanel>
+        <TextBlock Name="ErrorTipsText" Foreground="Red" Margin="150,4,0,0" Visibility="Collapsed" Grid.Row="4">Confirmation password is not the same as the set password, please re-enter it.</TextBlock>
+        <Grid Grid.Row="5">
+            <StackPanel  Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="24">
+                <Button x:Name="CancelBtn" Content="Cancel"  Margin="0,0,10,0" Width="112" Height="32" BorderThickness="1"></Button>
+                <Button x:Name="DoneBtn" Content="Done" Width="112" Height="32" BorderThickness="1" Click="DoneBtn_Click"></Button>
+            </StackPanel>
+        </Grid>
+    </Grid>
+</UserControl>

+ 92 - 0
Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/SaveCerficateControl.xaml.cs

@@ -0,0 +1,92 @@
+using ComPDFKit.DigitalSign;
+using Compdfkit_Tools.Helper;
+using System;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+using System.Security; 
+using System.Windows;
+using System.Windows.Controls;
+
+namespace Compdfkit_Tools.PDFControl
+{
+    /// <summary>
+    /// SaveCerficateControlControl.xaml 的交互逻辑
+    /// </summary>
+    public partial class SaveCerficateControl : UserControl, INotifyPropertyChanged
+    {
+        public CertificateInfo CertificateInfo;
+
+        public event PropertyChangedEventHandler PropertyChanged;
+
+        private string _filePath;
+        public string FilePath
+        {
+            get => _filePath;
+            set => UpdateProper(ref _filePath, value);
+        }
+
+        public SaveCerficateControl()
+        {
+            InitializeComponent();
+            this.DataContext = this;
+        }
+
+        private void SelectFileBtn_Click(object sender, RoutedEventArgs e)
+        {
+            string filePath = CommonHelper.GetGeneratePathOrEmpty("PFX Files(*.pfx) | *.pfx");
+            if (filePath != string.Empty)
+            {
+                FilePath = filePath;
+            } 
+        }
+         
+        private void DoneBtn_Click(object sender, RoutedEventArgs e)
+        {
+            if(FilePath == string.Empty)
+            {
+                return;
+            }
+
+            if (SetPasswordPbx.Password != string.Empty && SetPasswordPbx.Password == ConfirmPasswordPbx.Password)
+            {
+                CertificateInfo.Password = SetPasswordPbx.Password;
+            }
+            else
+            {
+                return;
+            }
+
+            string certificateInfo = "/";
+            certificateInfo += "C=" + CertificateInfo.Area;
+            if (CertificateInfo.Organization != string.Empty)
+            {
+                certificateInfo += "/O=" + CertificateInfo.Organization;
+            }
+            if (CertificateInfo.OrganizationUnit != string.Empty)
+            {
+                certificateInfo += "/D=" + CertificateInfo.OrganizationUnit;
+            }
+            certificateInfo += "/CN=" + CertificateInfo.GrantorName;
+            bool is_2048 = CertificateInfo.AlgorithmType == AlgorithmType.RSA2048bit;
+            CPDFPKCS12CertHelper.GeneratePKCS12Cert(certificateInfo, CertificateInfo.Password, FilePath, (int)CertificateInfo.PurposeType, is_2048);
+            FillDigitalSignatureDialog fillDigitalSignatureDialog = new FillDigitalSignatureDialog();
+            fillDigitalSignatureDialog.FilePath = FilePath;
+            fillDigitalSignatureDialog.ShowDialog();
+        }
+
+        protected void UpdateProper<T>(ref T properValue,
+                      T newValue,
+                      [CallerMemberName] string properName = "")
+        {
+            if (object.Equals(properValue, newValue))
+                return;
+
+            properValue = newValue;
+            OnPropertyChanged(properName);
+        }
+         
+        protected void OnPropertyChanged([CallerMemberName] string propertyName = "") =>
+    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+
+    }
+}

+ 0 - 40
Demo/Examples/Compdfkit_Tools/DigitalSignature/AddCertificationControl/SaveCustomCertificationControl.xaml.cs

@@ -1,40 +0,0 @@
-using System;
-using System.ComponentModel;
-using System.Runtime.CompilerServices;
-using System.Windows.Controls;
-
-namespace Compdfkit_Tools.DigitalSignature.AddCertificationControl
-{
-    public partial class SaveCustomCertificationControl : UserControl, INotifyPropertyChanged
-    {
-        private string _setPassword;
-        public string SetPassword
-        {
-            get => _setPassword;
-            set => UpdateProper(ref _setPassword, value);
-        }
-        
-        public SaveCustomCertificationControl()
-        {
-            InitializeComponent();
-        }
-        
-        public event PropertyChangedEventHandler PropertyChanged;
-
-        protected void UpdateProper<T>(ref T properValue,
-            T newValue,
-            [CallerMemberName] string properName = "")
-        {
-            if (object.Equals(properValue, newValue))
-                return;
-
-            properValue = newValue;
-            OnPropertyChanged(properName);
-        }
-
-        protected void OnPropertyChanged([CallerMemberName] string propertyName = "") =>
-            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
-
-        public event EventHandler<EventArgs> SaveEvent;
-    }
-}

+ 45 - 0
Demo/Examples/Compdfkit_Tools/DigitalSignature/DigitalSignatureData/DigitalSignatureData.cs

@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Compdfkit_Tools.PDFControl
+{
+    public enum CreateCertificationMode
+    {
+        AddExistedCertification,
+        AddCustomCertification,
+        SaveCertificate
+    }
+
+    public enum AlgorithmType
+    {
+        RSA1024bit,
+        RSA2048bit
+    }
+
+    public enum PurposeType
+    {
+        DigitalSignatures,
+        DataEncryption,
+        DigitalSignaturesAndDataEncryption
+    }
+
+    public class CertificateInfo
+    {
+        public string GrantorName = string.Empty; 
+        public string Organization = string.Empty;
+        public string OrganizationUnit = string.Empty;
+        public string Email = string.Empty;
+        public string Area = string.Empty;
+        public string Password = string.Empty;
+        public AlgorithmType AlgorithmType;
+        public PurposeType PurposeType;
+    }
+    
+    internal class DigitalSignatureData
+    {
+          
+    }
+}

+ 9 - 24
Demo/Examples/Compdfkit_Tools/DigitalSignature/FillDigitalSignatureControl/FillDigitalSignatureControl.xaml

@@ -6,7 +6,7 @@
              xmlns:local="clr-namespace:Compdfkit_Tools.PDFControl"
              mc:Ignorable="d" 
              d:DesignHeight="530" d:DesignWidth="630" 
-             Width="630" Height="530">
+             >
     <UserControl.Resources>
         <ResourceDictionary>
             <ResourceDictionary.MergedDictionaries>
@@ -20,7 +20,6 @@
         <Grid Name="MainGrid" Background="White">
             
             <Grid.RowDefinitions>
-                <RowDefinition Height="auto"></RowDefinition>
                 <RowDefinition Height="auto"></RowDefinition>
                 <RowDefinition Height="auto"></RowDefinition>
                 <RowDefinition Height="30"></RowDefinition>
@@ -29,22 +28,8 @@
                 <RowDefinition Height="auto"></RowDefinition>
             </Grid.RowDefinitions>
             
-            <TextBlock FontSize="14" Margin="25,16,0,0">Customized Appearance</TextBlock>
-            
-            <Button HorizontalAlignment="Right" Margin="0,8,10,0" Style="{StaticResource LightButtonStyle}" BorderThickness="0"
-              Background="White" Width="24" Height="24">
-                <Button.Content>
-                    <Path Fill="#43474D" Width="16" Height="16">
-                        <Path.Data>
-                            M12.6466 13.2531L13.0001 13.6066L13.7072 12.8995L13.3537 12.546L8.7072 7.8995L13.2532 3.35352L13.6067 2.99997L12.8996 
-                      2.29286L12.5461 2.64642L8.00009 7.19239L3.45418 2.64648L3.10063 2.29292L2.39352 3.00003L2.74708 3.35358L7.29299 
-                      7.8995L2.64657 12.5459L2.29302 12.8995L3.00013 13.6066L3.35368 13.253L8.0001 8.6066L12.6466 13.2531Z
-                        </Path.Data>
-                    </Path>
-                </Button.Content>
-            </Button>
-
-            <Grid Grid.Row="1" Width="314" HorizontalAlignment="Center" Margin="0,20,0,1">
+
+            <Grid Grid.Row="0" Width="314" HorizontalAlignment="Center" Margin="0,20,0,1">
                 <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="91"></ColumnDefinition>
                     <ColumnDefinition Width="87"></ColumnDefinition>
@@ -81,17 +66,17 @@
                 </Grid>
             </Grid>
 
-            <Canvas Grid.Row="2" Width="580" Height="187" Background="#F4F7FF">
-
+            <Canvas Grid.Row="1" Width="580" Height="187" Background="#F4F7FF">
+                <Image Width="580" Height="187" x:Name="imageControl" />
             </Canvas>
 
-            <StackPanel Grid.Row="3" Name="ImagePickPanel" HorizontalAlignment="Right" Orientation="Horizontal" Margin="0,6,30,0"
+            <StackPanel Grid.Row="2" Name="ImagePickPanel" HorizontalAlignment="Right" Orientation="Horizontal" Margin="0,6,30,0"
                         Visibility="Hidden">
                 <TextBlock Foreground="Blue">Browse</TextBlock>
                 <TextBlock Margin="10,0,0,0" Foreground="Blue">Clear</TextBlock>
             </StackPanel>
 
-            <Grid Grid.Row="4" Margin="25,0,25,0">
+            <Grid Grid.Row="3" Margin="25,0,25,0">
                 <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="*"></ColumnDefinition>
                     <ColumnDefinition Width="auto"></ColumnDefinition>
@@ -118,7 +103,7 @@
                 </StackPanel>
             </Grid>
 
-            <Grid Grid.Row="5" Margin="25,10,0,0">
+            <Grid Grid.Row="4" Margin="25,10,0,0">
                 <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="auto"></ColumnDefinition>
                     <ColumnDefinition Width="auto"></ColumnDefinition>
@@ -157,7 +142,7 @@
 
             </Grid>
 
-            <Grid Grid.Row="6" Margin="25,10,0,0">
+            <Grid Grid.Row="5" Margin="25,10,0,0">
                 <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="auto"></ColumnDefinition>
                     <ColumnDefinition Width="auto"></ColumnDefinition>

+ 97 - 25
Demo/Examples/Compdfkit_Tools/DigitalSignature/FillDigitalSignatureControl/FillDigitalSignatureControl.xaml.cs

@@ -1,5 +1,12 @@
-using System.Collections.Generic;
+using ComPDFKit.Import;
+using ComPDFKit.PDFAnnotation;
+using ComPDFKit.PDFAnnotation.Form;
+using ComPDFKit.PDFDocument;
+using ComPDFKit.PDFPage;
+using System;
+using System.Collections.Generic;
 using System.IO;
+using System.Reflection;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Controls.Primitives;
@@ -7,6 +14,7 @@ using System.Windows.Ink;
 using System.Windows.Input;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
+using System.Windows.Media.Media3D;
 
 namespace Compdfkit_Tools.PDFControl
 {
@@ -15,29 +23,93 @@ namespace Compdfkit_Tools.PDFControl
     /// </summary>
     public partial class FillDigitalSignatureControl : UserControl
     {
-        private Dictionary<string,Border> TabDict { get; set; }
+        private Dictionary<string, Border> TabDict { get; set; }
+
+        private SignatureConfig tempSignatureConfig = new SignatureConfig();
+
+        private string _filePath = string.Empty;
+        public string FilePath
+        {
+            get => _filePath;
+            set
+            {
+                _filePath = value;
+            }
+        }
+
         public FillDigitalSignatureControl()
         {
             InitializeComponent();
-            TabDict=new Dictionary<string,Border>();
-            TabDict["Keyboard"] = KeyboardBorder;
-            TabDict["Trackpad"] = TrackpadBorder;
-            TabDict["Image"] = ImageBorder;
-            TabDict["None"] = NoneBorder;
+            TabDict = new Dictionary<string, Border>
+            {
+                ["Keyboard"] = KeyboardBorder,
+                ["Trackpad"] = TrackpadBorder,
+                ["Image"] = ImageBorder,
+                ["None"] = NoneBorder
+            };
             SetCheckedTab("Keyboard");
+
+            CreateTempSignature();
+        }
+
+        private void CreateTempSignature()
+        {
+            CPDFDocument tempDocument = CPDFDocument.CreateDocument();
+            tempDocument.InsertPage(0, 200, 200, null);
+            CPDFPage page = tempDocument.PageAtIndex(0);
+            CPDFSignatureWidget signatureWidget = page.CreateWidget(C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS) as CPDFSignatureWidget;
+            signatureWidget.SetRect(new CRect(0, 100, 100, 0));
+            signatureWidget.UpdataApWithSignature(tempSignatureConfig);
+            signatureWidget.UpdateFormAp();
+            //if(signatureWidget.UpdateApWithImage("C:\\Users\\dkan\\Pictures\\Screenshots\\hao.jpg", "", 0))
+            //{
+            //    signatureWidget.UpdateAp();
+            //}
+            byte[] signatureBitmapBytes = GetTempSignatureImage(signatureWidget, out int width, out int height);
+            tempDocument.WriteToFilePath("E:\\testfile1.pdf");
+
+            signatureWidget.ReleaseAnnot();
+             
+            if (signatureBitmapBytes.Length > 0)
+            {
+                PixelFormat fmt = PixelFormats.Bgra32;
+                BitmapSource bps = BitmapSource.Create(width, height, 96, 96, fmt, null, signatureBitmapBytes, (width * fmt.BitsPerPixel + 7) / 8);
+                imageControl.Source = bps; 
+            }
+            else
+            {
+                imageControl.Source = null;
+            } 
+        }
+
+        public static byte[] GetTempSignatureImage(CPDFSignatureWidget signatureWidget, out int width, out int height)
+        {
+            CRect rect = signatureWidget.GetRect();
+
+            var flags = BindingFlags.NonPublic | BindingFlags.Static;
+            var dpiProperty = typeof(SystemParameters).GetProperty("Dpi", flags);
+            int dpi = (int)dpiProperty.GetValue(null, null);
+
+            width = (int)(rect.width() * dpi / 72D * 2);
+            height = (int)(rect.height() * dpi / 72D * 2);
+
+            byte[] imageData = new byte[width * height * 4];
+            signatureWidget.RenderAnnot(width, height, imageData, CPDFAppearanceType.Normal);
+
+            return imageData;
         }
 
         private void TextAlignBtn_Click(object sender, RoutedEventArgs e)
         {
-            ToggleButton checkBtn=sender as ToggleButton;
-            if(checkBtn == null)
+            ToggleButton checkBtn = sender as ToggleButton;
+            if (checkBtn == null)
             {
                 return;
             }
             checkBtn.IsChecked = true;
-            if(checkBtn!= TextAlignLeftBtn)
+            if (checkBtn != TextAlignLeftBtn)
             {
-                TextAlignLeftBtn.IsChecked= false;
+                TextAlignLeftBtn.IsChecked = false;
             }
             if (checkBtn != TextAlignRightBtn)
             {
@@ -48,18 +120,18 @@ namespace Compdfkit_Tools.PDFControl
         private void Border_MouseDown(object sender, MouseButtonEventArgs e)
         {
             Border clickBorder = sender as Border;
-            if(clickBorder == null || clickBorder.Tag==null)
+            if (clickBorder == null || clickBorder.Tag == null)
             {
                 return;
             }
             SetCheckedTab(clickBorder.Tag.ToString());
             ImagePickPanel.Visibility = Visibility.Hidden;
-            if (clickBorder== TrackpadBorder)
+            if (clickBorder == TrackpadBorder)
             {
                 CanvaDrawPopup.Visibility = Visibility.Visible;
             }
 
-            if(clickBorder== ImageBorder)
+            if (clickBorder == ImageBorder)
             {
                 ImagePickPanel.Visibility = Visibility.Visible;
             }
@@ -72,13 +144,13 @@ namespace Compdfkit_Tools.PDFControl
                 foreach (string key in TabDict.Keys)
                 {
                     Border checkBorder = TabDict[key];
-                    if(checkBorder == null)
+                    if (checkBorder == null)
                     {
                         continue;
                     }
 
                     checkBorder.BorderThickness = new Thickness(0);
-                    if(key==tab)
+                    if (key == tab)
                     {
                         checkBorder.BorderThickness = new Thickness(0, 0, 0, 2);
                     }
@@ -100,9 +172,9 @@ namespace Compdfkit_Tools.PDFControl
         {
             if (DrawInkCanvas != null && DrawInkCanvas.Strokes != null && DrawInkCanvas.Strokes.Count > 0)
             {
-                Rect bound= DrawInkCanvas.Strokes.GetBounds();
+                Rect bound = DrawInkCanvas.Strokes.GetBounds();
                 DrawingVisual drawVisual = new DrawingVisual();
-                DrawingContext drawContext= drawVisual.RenderOpen();
+                DrawingContext drawContext = drawVisual.RenderOpen();
 
                 foreach (Stroke drawStroke in DrawInkCanvas.Strokes)
                 {
@@ -113,11 +185,11 @@ namespace Compdfkit_Tools.PDFControl
                     Figures.Add(AddFigure);
                     drawPath.Figures = Figures;
 
-                    if(drawStroke.StylusPoints.Count>1)
+                    if (drawStroke.StylusPoints.Count > 1)
                     {
-                        StylusPoint startPoint= drawStroke.StylusPoints[0];
-                        AddFigure.StartPoint= new Point(startPoint.X - bound.X, startPoint.Y - bound.Y);
-                        for (int i = 1;i< drawStroke.StylusPoints.Count;i++)
+                        StylusPoint startPoint = drawStroke.StylusPoints[0];
+                        AddFigure.StartPoint = new Point(startPoint.X - bound.X, startPoint.Y - bound.Y);
+                        for (int i = 1; i < drawStroke.StylusPoints.Count; i++)
                         {
                             StylusPoint drawPoint = drawStroke.StylusPoints[i];
                             Point offsetPoint = new Point(drawPoint.X - bound.X, drawPoint.Y - bound.Y);
@@ -127,14 +199,14 @@ namespace Compdfkit_Tools.PDFControl
                         }
                     }
 
-                    if(AddFigure.Segments.Count > 0)
+                    if (AddFigure.Segments.Count > 0)
                     {
                         drawContext.DrawGeometry(null, drawPen, drawPath);
                     }
                 }
                 drawContext.Close();
 
-                RenderTargetBitmap renderBitmap=new RenderTargetBitmap((int)bound.Width,(int)bound.Height,96,96,PixelFormats.Pbgra32);
+                RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)bound.Width, (int)bound.Height, 96, 96, PixelFormats.Pbgra32);
                 renderBitmap.Render(drawVisual);
             }
         }
@@ -147,7 +219,7 @@ namespace Compdfkit_Tools.PDFControl
                 return;
             }
 
-            ReasonPanel.Visibility=checkItem.IsChecked==true? Visibility.Visible: Visibility.Collapsed;
+            ReasonPanel.Visibility = checkItem.IsChecked == true ? Visibility.Visible : Visibility.Collapsed;
         }
     }
 }

+ 13 - 0
Demo/Examples/Compdfkit_Tools/DigitalSignature/FillDigitalSignatureControl/FillDigitalSignatureDialog.xaml

@@ -0,0 +1,13 @@
+<Window x:Class="Compdfkit_Tools.PDFControl.FillDigitalSignatureDialog"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:local="clr-namespace:Compdfkit_Tools.PDFControl"
+        mc:Ignorable="d"
+        ResizeMode="NoResize"
+        Title="FillDigitalSignatureDialog"  Width="630" Height="550">
+    <Grid>
+        <local:FillDigitalSignatureControl x:Name="FillDigitalSignatureControl"></local:FillDigitalSignatureControl>
+    </Grid>
+</Window>

+ 38 - 0
Demo/Examples/Compdfkit_Tools/DigitalSignature/FillDigitalSignatureControl/FillDigitalSignatureDialog.xaml.cs

@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace Compdfkit_Tools.PDFControl
+{
+    /// <summary>
+    /// FillDigitalSignatureDialog.xaml 的交互逻辑
+    /// </summary>
+    public partial class FillDigitalSignatureDialog : Window
+    {
+        private string _filePath = string.Empty;
+        public string FilePath
+        {
+            get => _filePath;
+            set
+            {
+                _filePath = value;
+                FillDigitalSignatureControl.FilePath = value;
+            }
+        }
+
+        public FillDigitalSignatureDialog()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 1 - 1
Demo/Examples/Compdfkit_Tools/PageEdit/PDFPageInsert/CPDFPageInsertUI.xaml.cs

@@ -92,7 +92,7 @@ namespace Compdfkit_Tools.PDFControlUI
 
         private void SelectFileButton_Click(object sender, RoutedEventArgs e)
         {
-            string filePath = CommonHelper.GetFilePathOrEmpty();
+            string filePath = CommonHelper.GetExistedPathOrEmpty();
 
             if (filePath != string.Empty)
             {

+ 1 - 0
Demo/Examples/Compdfkit_Tools/packages.config

@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
   <package id="ComPDFKit.NetFramework" version="1.9.1" targetFramework="net461" />
+  <package id="Nager.Country" version="4.0.0" targetFramework="net461" />
   <package id="PresentationFramework.Aero2" version="1.0.1" targetFramework="net461" />
 </packages>

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

@@ -170,7 +170,7 @@ namespace ContentEditorViewControl
 
         private void OpenFile()
         {
-            string filePath = CommonHelper.GetFilePathOrEmpty();
+            string filePath = CommonHelper.GetExistedPathOrEmpty();
             if (!string.IsNullOrEmpty(filePath) && contentEditControl.PdfViewControl != null)
             {
                 if (pdfViewer.PDFView != null && pdfViewer.PDFView.Document != null)

+ 8 - 6
Demo/Examples/DigitalSignature/DigitalSignature.csproj

@@ -38,12 +38,6 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="ComPDFKit.Desk, Version=1.9.1.0, Culture=neutral, processorArchitecture=MSIL">
-      <HintPath>..\packages\ComPDFKit.NetFramework.1.9.1\lib\ComPDFKit.Desk.dll</HintPath>
-    </Reference>
-    <Reference Include="ComPDFKit.Viewer, Version=1.9.1.0, Culture=neutral, processorArchitecture=MSIL">
-      <HintPath>..\packages\ComPDFKit.NetFramework.1.9.1\lib\ComPDFKit.Viewer.dll</HintPath>
-    </Reference>
     <Reference Include="PresentationFramework.Aero2, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
       <HintPath>..\packages\PresentationFramework.Aero2.1.0.1\lib\PresentationFramework.Aero2.dll</HintPath>
     </Reference>
@@ -120,6 +114,14 @@
       <Project>{56e518ad-c126-4b48-9a09-0a64c87020e4}</Project>
       <Name>ComPDFKit.Desk</Name>
     </ProjectReference>
+    <ProjectReference Include="..\..\..\..\compdfkit\ComPDFKit\ComPDFKitCSharp\ComPDFKit.Desk.csproj">
+      <Project>{56e518ad-c126-4b48-9a09-0a64c87020e4}</Project>
+      <Name>ComPDFKit.Desk</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\..\compdfkit\ComPDFKit\ComPDFKitDesktop\ComPDFKit.Viewer\ComPDFKit.Viewer.csproj">
+      <Project>{18ec356d-8130-49d4-b4e6-ac290e1065b7}</Project>
+      <Name>ComPDFKit.Viewer</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\..\..\compdfkit\ComPDFKit\ComPDFKitDesktop\ComPDFKit.Viewer\ComPDFKit.Viewer.csproj">
       <Project>{18ec356d-8130-49d4-b4e6-ac290e1065b7}</Project>
       <Name>ComPDFKit.Viewer</Name>

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

@@ -105,7 +105,7 @@ namespace DigitalSignature
 
         private void OpenFile()
         {
-            string filePath = CommonHelper.GetFilePathOrEmpty();
+            string filePath = CommonHelper.GetExistedPathOrEmpty();
             string oldFilePath = pdfViewer.PDFView.Document.FilePath;
 
             if (!string.IsNullOrEmpty(filePath) && regularViewerControl.PdfViewControl != null)

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

@@ -184,7 +184,7 @@ namespace FormViewControl
         
         private void OpenFile()
         {
-            string filePath = CommonHelper.GetFilePathOrEmpty();
+            string filePath = CommonHelper.GetExistedPathOrEmpty();
             if (!string.IsNullOrEmpty(filePath) && formControl.PdfViewControl != null)
             {
                 if (pdfViewer.PDFView != null && pdfViewer.PDFView.Document != null)

+ 1 - 1
Demo/Examples/PDFViewer/MainPage.xaml.cs

@@ -248,7 +248,7 @@ namespace PDFViewer
 
         private void OpenFile()
         {
-            string filePath = CommonHelper.GetFilePathOrEmpty();
+            string filePath = CommonHelper.GetExistedPathOrEmpty();
             string oldFilePath = pdfViewer.PDFView.Document.FilePath;
 
             if (!string.IsNullOrEmpty(filePath) && regularViewerControl.PdfViewControl != null)

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

@@ -339,7 +339,7 @@ namespace PDFViewer
 
         private void DefaultAddButton_Click(object sender, RoutedEventArgs e)
         {
-            string filePath = CommonHelper.GetFilePathOrEmpty();
+            string filePath = CommonHelper.GetExistedPathOrEmpty();
             if (filePath != string.Empty)
             {
                 TabControlLoadDocument(filePath);

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

@@ -333,7 +333,7 @@ namespace Viewer
 
         private void OpenFile()
         {
-            string filePath = CommonHelper.GetFilePathOrEmpty();
+            string filePath = CommonHelper.GetExistedPathOrEmpty();
             if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
             {
                 if (pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)

BIN
Demo/Examples/packages/ComPDFKit.NetFramework.1.9.1/build/x64/ComPDFKit.dll


BIN
Demo/Examples/packages/Nager.Country.4.0.0/.signature.p7s


+ 21 - 0
Demo/Examples/packages/Nager.Country.4.0.0/LICENSE.md

@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2019 nager.at
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

BIN
Demo/Examples/packages/Nager.Country.4.0.0/Nager.Country.4.0.0.nupkg


+ 29 - 0
Demo/Examples/packages/Nager.Country.4.0.0/README.md

@@ -0,0 +1,29 @@
+# Nager.Country
+
+The Worldwirde Country Informations are available over the nuget package. The collection contains the Informations for 250 Countries.
+
+> If you need the translations of the countries you will find in the further nuget package [Nager.Country.Translation](https://www.nuget.org/packages/Nager.Country.Translation)
+
+## Code Examples
+
+### Get CountryInfo - Germany via Alpha2Code
+
+    ICountryProvider countryProvider = new CountryProvider();
+    var countryInfo = countryProvider.GetCountry(Alpha2Code.DE);
+    //countryInfo.CommonName -> Germany
+    //countryInfo.Alpha3Code -> DEU
+    //countryInfo.NumericCode -> 276
+    //countryInfo.Region -> Europe
+    //countryInfo.SubRegion -> WesternEurope
+    //countryInfo...
+
+### Get CountryInfo - Germany via CommonName
+
+    ICountryProvider countryProvider = new CountryProvider();
+    var countryInfo = countryProvider.GetCountryByName("Germany");
+    //countryInfo.Alpha2Code -> DE
+    //countryInfo.Alpha3Code -> DEU
+    //countryInfo.NumericCode -> 276
+    //countryInfo.Region -> Europe
+    //countryInfo.SubRegion -> WesternEurope
+    //countryInfo..

BIN
Demo/Examples/packages/Nager.Country.4.0.0/icon.png


BIN
Demo/Examples/packages/Nager.Country.4.0.0/lib/net48/Nager.Country.dll


File diff suppressed because it is too large
+ 16588 - 0
Demo/Examples/packages/Nager.Country.4.0.0/lib/net48/Nager.Country.xml


BIN
Demo/Examples/packages/Nager.Country.4.0.0/lib/net6.0/Nager.Country.dll


File diff suppressed because it is too large
+ 16588 - 0
Demo/Examples/packages/Nager.Country.4.0.0/lib/net6.0/Nager.Country.xml


BIN
Demo/Examples/packages/Nager.Country.4.0.0/lib/netstandard2.0/Nager.Country.dll


File diff suppressed because it is too large
+ 16588 - 0
Demo/Examples/packages/Nager.Country.4.0.0/lib/netstandard2.0/Nager.Country.xml


BIN
Demo/Examples/packages/Nager.Country.4.0.0/lib/netstandard2.1/Nager.Country.dll


File diff suppressed because it is too large
+ 16588 - 0
Demo/Examples/packages/Nager.Country.4.0.0/lib/netstandard2.1/Nager.Country.xml


+ 45 - 0
Demo/Examples/packages/Nager.Country.4.0.0/readme.txt

@@ -0,0 +1,45 @@
+
+████████ ██   ██  █████  ███    ██ ██   ██     ██    ██  ██████  ██    ██
+   ██    ██   ██ ██   ██ ████   ██ ██  ██       ██  ██  ██    ██ ██    ██
+   ██    ███████ ███████ ██ ██  ██ █████         ████   ██    ██ ██    ██
+   ██    ██   ██ ██   ██ ██  ██ ██ ██  ██         ██    ██    ██ ██    ██
+   ██    ██   ██ ██   ██ ██   ████ ██   ██        ██     ██████   ██████
+
+
+Thank you for using this project. This project is completely free for commercial use.
+
+However, if you use our project commercially we would like you to support us with a sponsorship.
+The maintenance and support costs time and we would like to ensure this for the future with your help.
+You can easily support us via the Github Sponsor function. https://github.com/sponsors/nager
+
+We would also be very happy about a GitHub Star ★
+
+Project Source: https://github.com/nager/Nager.Country
+
+
+
+Examples of use:
+
+Get CountryInfo for Germany via Alpha2Code
+══════════════════════════════════════════════════════════════════════════════════════════════════════
+
+    ICountryProvider countryProvider = new CountryProvider();
+    var countryInfo = countryProvider.GetCountry(Alpha2Code.DE);
+    //countryInfo.CommonName -> Germany
+    //countryInfo.Alpha3Code -> DEU
+    //countryInfo.NumericCode -> 276
+    //countryInfo.Region -> Europe
+    //countryInfo.SubRegion -> WesternEurope
+    //countryInfo...
+
+Get CountryInfo for Germany via CommonName
+══════════════════════════════════════════════════════════════════════════════════════════════════════
+
+    ICountryProvider countryProvider = new CountryProvider();
+    var countryInfo = countryProvider.GetCountryByName("Germany");
+    //countryInfo.Alpha2Code -> DE
+    //countryInfo.Alpha3Code -> DEU
+    //countryInfo.NumericCode -> 276
+    //countryInfo.Region -> Europe
+    //countryInfo.SubRegion -> WesternEurope
+    //countryInfo..