Jelajahi Sumber

compdfkit(windows) - try catch

liuaoran 1 tahun lalu
induk
melakukan
dc40cb275b

+ 8 - 15
Demo/Examples/Annotations/App.xaml.cs

@@ -47,22 +47,15 @@ namespace annotation_ctrl_demo
         private static bool LicenseVerify()
         {
             bool result = false;
-            try
-            {
-                result = CPDFSDKVerifier.LoadNativeLibrary();
-                if (!result)
-                    return false;
-            }
-            catch
-            { }
+
+            result = CPDFSDKVerifier.LoadNativeLibrary();
+            if (!result)
+                return false;
             SDKLicenseHelper sdkLicenseHelper = new SDKLicenseHelper();
-            try
-            {
-                LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(sdkLicenseHelper.key, sdkLicenseHelper.secret);
-                if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
-                    return false;
-            }
-            catch { }
+
+            LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(sdkLicenseHelper.key, sdkLicenseHelper.secret);
+            if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
+                return false;
             return result;
         }
     }

+ 11 - 15
Demo/Examples/Compdfkit_Tools/Annotation/PDFAnnotationList/PDFAnnotationListUI/CPDFAnnoationListUI.xaml.cs

@@ -98,12 +98,12 @@ namespace Compdfkit_Tools.PDFControlUI
             InitializeComponent();
             ICollectionView groupView = CollectionViewSource.GetDefaultView(annotationList);
             groupView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotationBindData.ShowPageIndex)));
-            popContextMenu=new ContextMenu();
-            MenuItem deleteMenu=new MenuItem();
+            popContextMenu = new ContextMenu();
+            MenuItem deleteMenu = new MenuItem();
             deleteMenu.Header = "Delete";
             deleteMenu.Click += DeleteMenu_Click;
             popContextMenu.Items.Add(deleteMenu);
-            MenuItem deleteAllMenu=new MenuItem();
+            MenuItem deleteAllMenu = new MenuItem();
             deleteAllMenu.Header = "Delete All";
             deleteAllMenu.Click += DeleteAllMenu_Click;
             popContextMenu.Items.Add(deleteAllMenu);
@@ -124,7 +124,7 @@ namespace Compdfkit_Tools.PDFControlUI
                     delDict[bindData.BindProperty.PageIndex].Add(bindData.BindProperty.AnnotIndex);
                 }
 
-                if(delDict.Count > 0)
+                if (delDict.Count > 0)
                 {
                     DeleteItemHandler?.Invoke(this, delDict);
                 }
@@ -143,7 +143,7 @@ namespace Compdfkit_Tools.PDFControlUI
                 {
                     AnnotationBindData bindData = annotationList[AnnotationList.SelectedIndex];
 
-                    Dictionary<int,List<int>> delDict=new Dictionary<int, List<int>>();
+                    Dictionary<int, List<int>> delDict = new Dictionary<int, List<int>>();
                     delDict[bindData.BindProperty.PageIndex] = new List<int>()
                     {
                         bindData.BindProperty.AnnotIndex
@@ -151,7 +151,7 @@ namespace Compdfkit_Tools.PDFControlUI
                     DeleteItemHandler?.Invoke(this, delDict);
                 }
             }
-            catch(Exception ex)
+            catch (Exception ex)
             {
 
             }
@@ -180,7 +180,7 @@ namespace Compdfkit_Tools.PDFControlUI
                 });
             }
             AnnotationList.ItemsSource = annotationList;
-            if(annotationList.Count > 0)
+            if (annotationList.Count > 0)
             {
                 AnnotationList.ContextMenu = popContextMenu;
             }
@@ -190,14 +190,10 @@ namespace Compdfkit_Tools.PDFControlUI
 
         private void AnnotationListControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            try
+            if (enableSelectEvent)
             {
-                if(enableSelectEvent)
-                {
-                    AnnotationSelectionChanged?.Invoke(this, (e.AddedItems[0] as AnnotationBindData).BindProperty);
-                }
+                AnnotationSelectionChanged?.Invoke(this, (e.AddedItems[0] as AnnotationBindData).BindProperty);
             }
-            catch { }
         }
 
 
@@ -213,7 +209,7 @@ namespace Compdfkit_Tools.PDFControlUI
             AnnotationList.SelectedIndex = annotationIndex;
         }
 
-        public void  SelectAnnotationChanged(int pageIIndex,int annotIndex)
+        public void SelectAnnotationChanged(int pageIIndex, int annotIndex)
         {
             if (annotationList != null && annotationList.Count > 0)
             {
@@ -246,7 +242,7 @@ namespace Compdfkit_Tools.PDFControlUI
                 }
 
             }
-            catch(Exception ex)
+            catch (Exception ex)
             {
 
             }

+ 10 - 17
Demo/Examples/Compdfkit_Tools/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs

@@ -456,7 +456,7 @@ namespace Compdfkit_Tools.PDFControl
                 }
                 catch
                 {
-                    var i =  pdfStampUI.CustomStampList.IndexOf(stamp);
+                    var i = pdfStampUI.CustomStampList.IndexOf(stamp);
                     Settings.Default.CustomStampList.RemoveAt(i);
                     Settings.Default.Save();
                     pdfStampUI.LoadSettings();
@@ -476,26 +476,19 @@ namespace Compdfkit_Tools.PDFControl
         private void CPDFAnnotationControl_PropertyChanged(object sender, CPDFAnnotationData e)
         {
             SetAnnotationProperty(e);
-
-            try
+            if (pdfViewer != null && pdfViewer.MouseMode == MouseModes.AnnotCreate && pdfViewer.ToolManager.CurrentAnnotArgs is FreehandAnnotArgs)
             {
-                if (pdfViewer != null && pdfViewer.MouseMode == MouseModes.AnnotCreate && pdfViewer.ToolManager.CurrentAnnotArgs is FreehandAnnotArgs)
+                FreehandAnnotArgs freehandArgs = pdfViewer.ToolManager.CurrentAnnotArgs as FreehandAnnotArgs;
+                CPDFFreehandData freehandData = e as CPDFFreehandData;
+                if (freehandData != null)
                 {
-                    FreehandAnnotArgs freehandArgs = pdfViewer.ToolManager.CurrentAnnotArgs as FreehandAnnotArgs;
-                    CPDFFreehandData freehandData = e as CPDFFreehandData;
-                    if (freehandData != null)
-                    {
-                        freehandArgs.InkColor = freehandData.BorderColor;
-                        freehandArgs.LineWidth = freehandData.Thickness;
-                        freehandArgs.Transparency = freehandData.Opacity;
-                        freehandArgs.Content = freehandData.Note;
-                        freehandArgs.Author = freehandData.Author;
-                    }
+                    freehandArgs.InkColor = freehandData.BorderColor;
+                    freehandArgs.LineWidth = freehandData.Thickness;
+                    freehandArgs.Transparency = freehandData.Opacity;
+                    freehandArgs.Content = freehandData.Note;
+                    freehandArgs.Author = freehandData.Author;
                 }
             }
-            catch (Exception ex)
-            {
-            }
         }
 
         /// <summary>

+ 0 - 3
Demo/Examples/Compdfkit_Tools/Common/PropertyControl/PDFArrow/CPDFArrowUI.xaml.cs

@@ -16,9 +16,6 @@ using System.Windows.Shapes;
 
 namespace Compdfkit_Tools.Common
 {
-    /// <summary>
-    /// CPDFArrowControl.xaml 的交互逻辑
-    /// </summary>
     public partial class CPDFArrowUI : UserControl, INotifyPropertyChanged
     {
         public event EventHandler ArrowChanged;

+ 9 - 19
Demo/Examples/ContentEditor/App.xaml.cs

@@ -41,28 +41,18 @@ namespace ContentEditor
 
         private static bool LicenseVerify()
         {
-            try
-            {
-                if (!CPDFSDKVerifier.LoadNativeLibrary())
-                {
-                    return false;
-                }
-                SDKLicenseHelper sdkLicenseHelper = new SDKLicenseHelper();
-                LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(sdkLicenseHelper.key, sdkLicenseHelper.secret);
-                if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
-                {
-                    return false;
-                }
+            bool result = false;
 
-                return true;
+            result = CPDFSDKVerifier.LoadNativeLibrary();
+            if (!result)
+                return false;
 
-            }
-            catch(Exception ex)
-            {
-
-            }
+            SDKLicenseHelper sdkLicenseHelper = new SDKLicenseHelper();
 
-            return false;
+            LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(sdkLicenseHelper.key, sdkLicenseHelper.secret);
+            if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
+                return false;
+            return result;
         }
     }
 }

+ 10 - 19
Demo/Examples/DocsEditor/App.xaml.cs

@@ -29,11 +29,8 @@ namespace DocsEditor
                 secret = node.Attributes["secret"].Value;
             }
         }
-
     }
-    /// <summary>
-    /// App.xaml 的交互逻辑
-    /// </summary>
+
     public partial class App : Application
     {
         protected override void OnStartup(StartupEventArgs e)
@@ -46,22 +43,16 @@ namespace DocsEditor
         private static bool LicenseVerify()
         {
             bool result = false;
-            try
-            {
-                result = CPDFSDKVerifier.LoadNativeLibrary();
-                if (!result)
-                    return false;
-            }
-            catch
-            { }
+
+            result = CPDFSDKVerifier.LoadNativeLibrary();
+            if (!result)
+                return false;
+
             SDKLicenseHelper sdkLicenseHelper = new SDKLicenseHelper();
-            try
-            {
-                LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(sdkLicenseHelper.key, sdkLicenseHelper.secret);
-                if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
-                    return false;
-            }
-            catch { }
+
+            LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(sdkLicenseHelper.key, sdkLicenseHelper.secret);
+            if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
+                return false;
             return result;
         }
     }

+ 65 - 96
Demo/Examples/DocsEditor/MainWindow.xaml.cs

@@ -29,9 +29,6 @@ using ComPDFKitViewer.PdfViewer;
 
 namespace DocsEditor
 {
-    /// <summary>
-    /// MainWindow.xaml 的交互逻辑
-    /// </summary>
     public partial class MainWindow : Window, INotifyPropertyChanged
     {
         private bool isFirstLoad = true;
@@ -128,35 +125,28 @@ namespace DocsEditor
 
         private void CopyImage_Click(object sender, RoutedEventArgs e)
         {
-            try
-            {
-                Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
+            Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
 
-                if (imageDict != null && imageDict.Count > 0)
+            if (imageDict != null && imageDict.Count > 0)
+            {
+                foreach (int pageIndex in imageDict.Keys)
                 {
-                    foreach (int pageIndex in imageDict.Keys)
+                    List<Bitmap> imageList = imageDict[pageIndex];
+                    foreach (Bitmap image in imageList)
                     {
-                        List<Bitmap> imageList = imageDict[pageIndex];
-                        foreach (Bitmap image in imageList)
-                        {
-                            MemoryStream ms = new MemoryStream();
-                            image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
-                            BitmapImage imageData = new BitmapImage();
-                            imageData.BeginInit();
-                            imageData.StreamSource = ms;
-                            imageData.CacheOption = BitmapCacheOption.OnLoad;
-                            imageData.EndInit();
-                            imageData.Freeze();
-                            Clipboard.SetImage(imageData);
-                            break;
-                        }
+                        MemoryStream ms = new MemoryStream();
+                        image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
+                        BitmapImage imageData = new BitmapImage();
+                        imageData.BeginInit();
+                        imageData.StreamSource = ms;
+                        imageData.CacheOption = BitmapCacheOption.OnLoad;
+                        imageData.EndInit();
+                        imageData.Freeze();
+                        Clipboard.SetImage(imageData);
+                        break;
                     }
                 }
             }
-            catch (Exception ex)
-            {
-
-            }
         }
 
         private void ExtraImage_Click(object sender, RoutedEventArgs e)
@@ -166,29 +156,22 @@ namespace DocsEditor
             {
                 string choosePath = folderDialog.SelectedPath;
                 string openPath = choosePath;
-                try
-                {
-                    Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
+                Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
 
-                    if (imageDict != null && imageDict.Count > 0)
+                if (imageDict != null && imageDict.Count > 0)
+                {
+                    foreach (int pageIndex in imageDict.Keys)
                     {
-                        foreach (int pageIndex in imageDict.Keys)
+                        List<Bitmap> imageList = imageDict[pageIndex];
+                        foreach (Bitmap image in imageList)
                         {
-                            List<Bitmap> imageList = imageDict[pageIndex];
-                            foreach (Bitmap image in imageList)
-                            {
-                                string savePath = System.IO.Path.Combine(choosePath, Guid.NewGuid() + ".jpg");
-                                image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
-                                openPath = savePath;
-                            }
+                            string savePath = System.IO.Path.Combine(choosePath, Guid.NewGuid() + ".jpg");
+                            image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
+                            openPath = savePath;
                         }
                     }
-                    Process.Start("explorer", "/select,\"" + openPath + "\"");
-                }
-                catch (Exception ex)
-                {
-
                 }
+                Process.Start("explorer", "/select,\"" + openPath + "\"");
 
             }
         }
@@ -398,7 +381,7 @@ namespace DocsEditor
                 pageEditControl.ExitPageEdit -= PageEditControl_ExitPageEdit;
                 pageEditControl.ExitPageEdit += PageEditControl_ExitPageEdit;
 
-                pageEditControl.PageMoved -= PageEditControl_PageMoved; 
+                pageEditControl.PageMoved -= PageEditControl_PageMoved;
                 pageEditControl.PageMoved += PageEditControl_PageMoved;
 
                 CPDFPageEditBarControl.PageEditEvent -= CPDFPageEditBarControl_PageEditEvent;
@@ -435,7 +418,7 @@ namespace DocsEditor
 
         private void PageEditControl_PageMoved(object sender, RoutedEventArgs e)
         {
-            if(pdfViewControl == null || pdfViewControl.PDFView == null)
+            if (pdfViewControl == null || pdfViewControl.PDFView == null)
             {
                 return;
             }
@@ -449,45 +432,38 @@ namespace DocsEditor
 
         private void OpenFile_Click(object sender, RoutedEventArgs e)
         {
-            try
+            string filePath = CommonHelper.GetFilePathOrEmpty();
+            if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
             {
-                string filePath = CommonHelper.GetFilePathOrEmpty();
-                if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
+                if (pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
                 {
-                    if (pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
-                    {
-                        string oldFilePath = pdfViewControl.PDFView.Document.FilePath;
-                        if (oldFilePath.ToLower() == filePath.ToLower())
-                        {
-                            return;
-                        }
-                    }
-
-                    passwordViewer = new PDFViewControl();
-                    passwordViewer.PDFView.InitDocument(filePath);
-                    if (passwordViewer.PDFView.Document == null)
+                    string oldFilePath = pdfViewControl.PDFView.Document.FilePath;
+                    if (oldFilePath.ToLower() == filePath.ToLower())
                     {
-                        MessageBox.Show("Open File Failed");
                         return;
                     }
+                }
 
-                    if (passwordViewer.PDFView.Document.IsLocked)
-                    {
-                        PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " password encrypted.");
-                        PasswordUI.ClearPassword();
-                        PopupBorder.Visibility = Visibility.Visible;
-                        PasswordUI.Visibility = Visibility.Visible;
-                    }
-                    else
-                    {
-                        pdfViewControl = passwordViewer;
-                        LoadDocument();
-                    }
+                passwordViewer = new PDFViewControl();
+                passwordViewer.PDFView.InitDocument(filePath);
+                if (passwordViewer.PDFView.Document == null)
+                {
+                    MessageBox.Show("Open File Failed");
+                    return;
                 }
-            }
-            catch (Exception ex)
-            {
 
+                if (passwordViewer.PDFView.Document.IsLocked)
+                {
+                    PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " password encrypted.");
+                    PasswordUI.ClearPassword();
+                    PopupBorder.Visibility = Visibility.Visible;
+                    PasswordUI.Visibility = Visibility.Visible;
+                }
+                else
+                {
+                    pdfViewControl = passwordViewer;
+                    LoadDocument();
+                }
             }
         }
 
@@ -537,27 +513,20 @@ namespace DocsEditor
         {
             if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
             {
-                try
+                CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
+                if (pdfDoc.WriteToLoadedPath())
                 {
-                    CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
-                    if (pdfDoc.WriteToLoadedPath())
-                    {
-                        return;
-                    }
+                    return;
+                }
 
-                    SaveFileDialog saveDialog = new SaveFileDialog();
-                    saveDialog.Filter = "(*.pdf)|*.pdf";
-                    saveDialog.DefaultExt = ".pdf";
-                    saveDialog.OverwritePrompt = true;
+                SaveFileDialog saveDialog = new SaveFileDialog();
+                saveDialog.Filter = "(*.pdf)|*.pdf";
+                saveDialog.DefaultExt = ".pdf";
+                saveDialog.OverwritePrompt = true;
 
-                    if (saveDialog.ShowDialog() == true)
-                    {
-                        pdfDoc.WriteToFilePath(saveDialog.FileName);
-                    }
-                }
-                catch (Exception ex)
+                if (saveDialog.ShowDialog() == true)
                 {
-
+                    pdfDoc.WriteToFilePath(saveDialog.FileName);
                 }
             }
         }
@@ -566,7 +535,7 @@ namespace DocsEditor
         {
             PopupBorder.Visibility = Visibility.Collapsed;
         }
-      
+
 
         private void ExpandSearchBtn_Click(object sender, RoutedEventArgs e)
         {
@@ -641,7 +610,7 @@ namespace DocsEditor
 
         private void InitPageEditControl()
         {
-            
+
         }
 
         private void ViewComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -680,7 +649,7 @@ namespace DocsEditor
             else if ((string)item.Content == "Page Edit")
             {
                 ToolBarContainer.Visibility = Visibility.Visible;
-                if(pageEditControl == null)
+                if (pageEditControl == null)
                 {
                     pageEditControl = new CPDFPageEditControl();
                 }

+ 8 - 15
Demo/Examples/Forms/App.xaml.cs

@@ -44,22 +44,15 @@ namespace Forms
         private static bool LicenseVerify()
         {
             bool result = false;
-            try
-            {
-                result = CPDFSDKVerifier.LoadNativeLibrary();
-                if (!result)
-                    return false;
-            }
-            catch
-            { }
+            result = CPDFSDKVerifier.LoadNativeLibrary();
+            if (!result)
+                return false;
+
             SDKLicenseHelper sdkLicenseHelper = new SDKLicenseHelper();
-            try
-            {
-                LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(sdkLicenseHelper.key, sdkLicenseHelper.secret);
-                if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
-                    return false;
-            }
-            catch { }
+
+            LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(sdkLicenseHelper.key, sdkLicenseHelper.secret);
+            if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
+                return false;
             return result;
         }
     }

+ 63 - 94
Demo/Examples/Forms/MainWindow.xaml.cs

@@ -29,9 +29,6 @@ using System.Runtime.CompilerServices;
 
 namespace Forms
 {
-    /// <summary>
-    /// Interaction logic for MainWindow.xaml
-    /// </summary>
     public partial class MainWindow : Window, INotifyPropertyChanged
     {
         #region property
@@ -495,44 +492,38 @@ namespace Forms
 
         private void OpenFile_Click(object sender, RoutedEventArgs e)
         {
-            try
+            string filePath = CommonHelper.GetFilePathOrEmpty();
+            if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
             {
-                string filePath = CommonHelper.GetFilePathOrEmpty();
-                if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
+                if (pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
                 {
-                    if (pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
+                    string oldFilePath = pdfViewControl.PDFView.Document.FilePath;
+                    if (oldFilePath.ToLower() == filePath.ToLower())
                     {
-                        string oldFilePath = pdfViewControl.PDFView.Document.FilePath;
-                        if (oldFilePath.ToLower() == filePath.ToLower())
-                        {
-                            return;
-                        }
-                    }
-
-                    passwordViewer = new PDFViewControl();
-                    passwordViewer.PDFView.InitDocument(filePath);
-                    if (passwordViewer.PDFView.Document == null)
-                    {
-                        MessageBox.Show("Open File Failed");
                         return;
                     }
+                }
 
-                    if (passwordViewer.PDFView.Document.IsLocked)
-                    {
-                        PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " password encrypted.");
-                        PasswordUI.ClearPassword();
-                        PopupBorder.Visibility = Visibility.Visible;
-                        PasswordUI.Visibility = Visibility.Visible;
-                    }
-                    else
-                    {
-                        pdfViewControl = passwordViewer;
-                        LoadDocument();
-                    }
+                passwordViewer = new PDFViewControl();
+                passwordViewer.PDFView.InitDocument(filePath);
+                if (passwordViewer.PDFView.Document == null)
+                {
+                    MessageBox.Show("Open File Failed");
+                    return;
+                }
+
+                if (passwordViewer.PDFView.Document.IsLocked)
+                {
+                    PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " password encrypted.");
+                    PasswordUI.ClearPassword();
+                    PopupBorder.Visibility = Visibility.Visible;
+                    PasswordUI.Visibility = Visibility.Visible;
+                }
+                else
+                {
+                    pdfViewControl = passwordViewer;
+                    LoadDocument();
                 }
-            }
-            catch (Exception ex)
-            {
             }
         }
 
@@ -543,35 +534,28 @@ namespace Forms
 
         private void CopyImage_Click(object sender, RoutedEventArgs e)
         {
-            try
-            {
-                Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
+            Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
 
-                if (imageDict != null && imageDict.Count > 0)
+            if (imageDict != null && imageDict.Count > 0)
+            {
+                foreach (int pageIndex in imageDict.Keys)
                 {
-                    foreach (int pageIndex in imageDict.Keys)
+                    List<Bitmap> imageList = imageDict[pageIndex];
+                    foreach (Bitmap image in imageList)
                     {
-                        List<Bitmap> imageList = imageDict[pageIndex];
-                        foreach (Bitmap image in imageList)
-                        {
-                            MemoryStream ms = new MemoryStream();
-                            image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
-                            BitmapImage imageData = new BitmapImage();
-                            imageData.BeginInit();
-                            imageData.StreamSource = ms;
-                            imageData.CacheOption = BitmapCacheOption.OnLoad;
-                            imageData.EndInit();
-                            imageData.Freeze();
-                            Clipboard.SetImage(imageData);
-                            break;
-                        }
+                        MemoryStream ms = new MemoryStream();
+                        image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
+                        BitmapImage imageData = new BitmapImage();
+                        imageData.BeginInit();
+                        imageData.StreamSource = ms;
+                        imageData.CacheOption = BitmapCacheOption.OnLoad;
+                        imageData.EndInit();
+                        imageData.Freeze();
+                        Clipboard.SetImage(imageData);
+                        break;
                     }
                 }
             }
-            catch (Exception ex)
-            {
-
-            }
         }
 
         private void ExtraImage_Click(object sender, RoutedEventArgs e)
@@ -581,30 +565,22 @@ namespace Forms
             {
                 string choosePath = folderDialog.SelectedPath;
                 string openPath = choosePath;
-                try
-                {
-                    Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
+                Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
 
-                    if (imageDict != null && imageDict.Count > 0)
+                if (imageDict != null && imageDict.Count > 0)
+                {
+                    foreach (int pageIndex in imageDict.Keys)
                     {
-                        foreach (int pageIndex in imageDict.Keys)
+                        List<Bitmap> imageList = imageDict[pageIndex];
+                        foreach (Bitmap image in imageList)
                         {
-                            List<Bitmap> imageList = imageDict[pageIndex];
-                            foreach (Bitmap image in imageList)
-                            {
-                                string savePath = System.IO.Path.Combine(choosePath, Guid.NewGuid() + ".jpg");
-                                image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
-                                openPath = savePath;
-                            }
+                            string savePath = System.IO.Path.Combine(choosePath, Guid.NewGuid() + ".jpg");
+                            image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
+                            openPath = savePath;
                         }
                     }
-                    Process.Start("explorer", "/select,\"" + openPath + "\"");
-                }
-                catch (Exception ex)
-                {
-
                 }
-
+                Process.Start("explorer", "/select,\"" + openPath + "\"");
             }
         }
 
@@ -768,7 +744,7 @@ namespace Forms
                     }
                     pdfViewControl.PDFView.SelectAnnotation(editEvent.PageIndex, editEvent.AnnotIndex);
                 }
-                else if (editEvent.EditAction==ActionType.Del)
+                else if (editEvent.EditAction == ActionType.Del)
                 {
                     fromPropertyControl.CleanProperty();
                 }
@@ -790,28 +766,21 @@ namespace Forms
         {
             if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
             {
-                try
+                CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
+                if (pdfDoc.WriteToLoadedPath())
                 {
-                    CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
-                    if (pdfDoc.WriteToLoadedPath())
-                    {
-                        pdfViewControl.PDFView.UndoManager.CanSave = false;
-                        return;
-                    }
+                    pdfViewControl.PDFView.UndoManager.CanSave = false;
+                    return;
+                }
 
-                    SaveFileDialog saveDialog = new SaveFileDialog();
-                    saveDialog.Filter = "(*.pdf)|*.pdf";
-                    saveDialog.DefaultExt = ".pdf";
-                    saveDialog.OverwritePrompt = true;
+                SaveFileDialog saveDialog = new SaveFileDialog();
+                saveDialog.Filter = "(*.pdf)|*.pdf";
+                saveDialog.DefaultExt = ".pdf";
+                saveDialog.OverwritePrompt = true;
 
-                    if (saveDialog.ShowDialog() == true)
-                    {
-                        pdfDoc.WriteToFilePath(saveDialog.FileName);
-                    }
-                }
-                catch (Exception ex)
+                if (saveDialog.ShowDialog() == true)
                 {
-
+                    pdfDoc.WriteToFilePath(saveDialog.FileName);
                 }
             }
         }

+ 7 - 16
Demo/Examples/PDFViewer/App.xaml.cs

@@ -16,7 +16,7 @@ namespace PDFViewer
         public string key = string.Empty;
         public string secret = string.Empty;
         public SDKLicenseHelper()
-        { 
+        {
             string sdkLicensePath = "license_key_win.xml";
             Assembly assembly = Assembly.GetExecutingAssembly();
             XmlDocument xmlDocument = new XmlDocument();
@@ -50,22 +50,13 @@ namespace PDFViewer
         private static bool LicenseVerify()
         {
             bool result = false;
-            try
-            {
-                result = CPDFSDKVerifier.LoadNativeLibrary();
-                if (!result)
-                    return false;
-            }
-            catch
-            { }
+            result = CPDFSDKVerifier.LoadNativeLibrary();
+            if (!result)
+                return false;
             SDKLicenseHelper sdkLicenseHelper = new SDKLicenseHelper();
-            try
-            {
-                LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(sdkLicenseHelper.key, sdkLicenseHelper.secret);
-                if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
-                    return false;
-            }
-            catch { }
+            LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(sdkLicenseHelper.key, sdkLicenseHelper.secret);
+            if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
+                return false;
             return result;
         }
     }

+ 84 - 127
Demo/Examples/PDFViewer/MainPage.xaml.cs

@@ -312,7 +312,7 @@ namespace PDFViewer
                 }
             }
         }
-         
+
         private void PDFImageEditButton_Click(object sender, RoutedEventArgs e)
         {
             ToggleButton senderBtn = sender as ToggleButton;
@@ -351,7 +351,7 @@ namespace PDFViewer
                 pdfViewControl.PDFView.UndoManager?.Redo();
             }
         }
-         
+
         private void ClearPDFEditState(ToggleButton ignoreBtn = null)
         {
             List<ToggleButton> clearBtnList = new List<ToggleButton>()
@@ -664,24 +664,17 @@ namespace PDFViewer
                             {
                                 string choosePath = folderBrowser.SelectedPath;
                                 string openPath = choosePath;
-                                try
+                                foreach (int pageIndex in imageDict.Keys)
                                 {
-                                    foreach (int pageIndex in imageDict.Keys)
+                                    List<Bitmap> imageList = imageDict[pageIndex];
+                                    foreach (Bitmap image in imageList)
                                     {
-                                        List<Bitmap> imageList = imageDict[pageIndex];
-                                        foreach (Bitmap image in imageList)
-                                        {
-                                            string savePath = System.IO.Path.Combine(choosePath, Guid.NewGuid() + ".jpg");
-                                            image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
-                                            openPath = savePath;
-                                        }
+                                        string savePath = System.IO.Path.Combine(choosePath, Guid.NewGuid() + ".jpg");
+                                        image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
+                                        openPath = savePath;
                                     }
-                                    Process.Start("explorer", "/select,\"" + openPath + "\"");
-                                }
-                                catch (Exception ex)
-                                {
-
                                 }
+                                Process.Start("explorer", "/select,\"" + openPath + "\"");
                             }
                         }
                     }
@@ -773,64 +766,49 @@ namespace PDFViewer
             {
                 string choosePath = folderDialog.SelectedPath;
                 string openPath = choosePath;
-                try
-                {
-                    Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
+                Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
 
-                    if (imageDict != null && imageDict.Count > 0)
+                if (imageDict != null && imageDict.Count > 0)
+                {
+                    foreach (int pageIndex in imageDict.Keys)
                     {
-                        foreach (int pageIndex in imageDict.Keys)
+                        List<Bitmap> imageList = imageDict[pageIndex];
+                        foreach (Bitmap image in imageList)
                         {
-                            List<Bitmap> imageList = imageDict[pageIndex];
-                            foreach (Bitmap image in imageList)
-                            {
-                                string savePath = Path.Combine(choosePath, Guid.NewGuid() + ".jpg");
-                                image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
-                                openPath = savePath;
-                            }
+                            string savePath = Path.Combine(choosePath, Guid.NewGuid() + ".jpg");
+                            image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
+                            openPath = savePath;
                         }
                     }
-                    Process.Start("explorer", "/select,\"" + openPath + "\"");
-                }
-                catch (Exception ex)
-                {
-
                 }
-
+                Process.Start("explorer", "/select,\"" + openPath + "\"");
             }
         }
 
         private void CopyImage_Click(object sender, RoutedEventArgs e)
         {
-            try
-            {
-                Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
+            Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
 
-                if (imageDict != null && imageDict.Count > 0)
+            if (imageDict != null && imageDict.Count > 0)
+            {
+                foreach (int pageIndex in imageDict.Keys)
                 {
-                    foreach (int pageIndex in imageDict.Keys)
+                    List<Bitmap> imageList = imageDict[pageIndex];
+                    foreach (Bitmap image in imageList)
                     {
-                        List<Bitmap> imageList = imageDict[pageIndex];
-                        foreach (Bitmap image in imageList)
-                        {
-                            MemoryStream ms = new MemoryStream();
-                            image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
-                            BitmapImage imageData = new BitmapImage();
-                            imageData.BeginInit();
-                            imageData.StreamSource = ms;
-                            imageData.CacheOption = BitmapCacheOption.OnLoad;
-                            imageData.EndInit();
-                            imageData.Freeze();
-                            Clipboard.SetImage(imageData);
-                            break;
-                        }
+                        MemoryStream ms = new MemoryStream();
+                        image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
+                        BitmapImage imageData = new BitmapImage();
+                        imageData.BeginInit();
+                        imageData.StreamSource = ms;
+                        imageData.CacheOption = BitmapCacheOption.OnLoad;
+                        imageData.EndInit();
+                        imageData.Freeze();
+                        Clipboard.SetImage(imageData);
+                        break;
                     }
                 }
             }
-            catch (Exception ex)
-            {
-
-            }
         }
         #endregion
 
@@ -839,7 +817,7 @@ namespace PDFViewer
         protected void OnPropertyChanged([CallerMemberName] string name = null)
         {
             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
-        } 
+        }
 
         #endregion
 
@@ -909,22 +887,15 @@ namespace PDFViewer
             {
                 if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
                 {
-                    try
-                    {
-                        CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
-                        SaveFileDialog saveDialog = new SaveFileDialog();
-                        saveDialog.Filter = "(*.pdf)|*.pdf";
-                        saveDialog.DefaultExt = ".pdf";
-                        saveDialog.OverwritePrompt = true;
+                    CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
+                    SaveFileDialog saveDialog = new SaveFileDialog();
+                    saveDialog.Filter = "(*.pdf)|*.pdf";
+                    saveDialog.DefaultExt = ".pdf";
+                    saveDialog.OverwritePrompt = true;
 
-                        if (saveDialog.ShowDialog() == true)
-                        {
-                            pdfDoc.WriteToFilePath(saveDialog.FileName);
-                        }
-                    }
-                    catch (Exception ex)
+                    if (saveDialog.ShowDialog() == true)
                     {
-
+                        pdfDoc.WriteToFilePath(saveDialog.FileName);
                     }
                 }
             }
@@ -937,80 +908,66 @@ namespace PDFViewer
         {
             if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
             {
-                try
+                CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
+                if (pdfDoc.WriteToLoadedPath())
                 {
-                    CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
-                    if (pdfDoc.WriteToLoadedPath())
-                    {
-                        pdfViewControl.PDFView.UndoManager.CanSave = false;
-                        return;
-                    }
+                    pdfViewControl.PDFView.UndoManager.CanSave = false;
+                    return;
+                }
 
-                    SaveFileDialog saveDialog = new SaveFileDialog();
-                    saveDialog.Filter = "(*.pdf)|*.pdf";
-                    saveDialog.DefaultExt = ".pdf";
-                    saveDialog.OverwritePrompt = true;
+                SaveFileDialog saveDialog = new SaveFileDialog();
+                saveDialog.Filter = "(*.pdf)|*.pdf";
+                saveDialog.DefaultExt = ".pdf";
+                saveDialog.OverwritePrompt = true;
 
-                    if (saveDialog.ShowDialog() == true)
-                    {
-                        pdfDoc.WriteToFilePath(saveDialog.FileName);
-                    }
-                }
-                catch (Exception ex)
+                if (saveDialog.ShowDialog() == true)
                 {
-
+                    pdfDoc.WriteToFilePath(saveDialog.FileName);
                 }
             }
         }
 
         public void OpenFile()
         {
-            try
-            {
-                string filePath = CommonHelper.GetFilePathOrEmpty();
-                string oldFilePath = pdfViewControl.PDFView.Document.FilePath;
+            string filePath = CommonHelper.GetFilePathOrEmpty();
+            string oldFilePath = pdfViewControl.PDFView.Document.FilePath;
 
-                if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
+            if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
+            {
+                if (pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
                 {
-                    if (pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
-                    {
-                        if (oldFilePath.ToLower() == filePath.ToLower())
-                        {
-                            return;
-                        }
-                    }
-
-                    if ((bool)CheckExistBeforeOpenFileEvent?.Invoke(new string[] { filePath, oldFilePath }))
+                    if (oldFilePath.ToLower() == filePath.ToLower())
                     {
                         return;
                     }
+                }
 
-                    passwordViewer = new PDFViewControl();
-                    passwordViewer.PDFView.InitDocument(filePath);
-                    if (passwordViewer.PDFView.Document == null)
-                    {
-                        MessageBox.Show("Open File Failed");
-                        return;
-                    }
+                if ((bool)CheckExistBeforeOpenFileEvent?.Invoke(new string[] { filePath, oldFilePath }))
+                {
+                    return;
+                }
 
-                    if (passwordViewer.PDFView.Document.IsLocked)
-                    {
-                        PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " password encrypted.");
-                        PasswordUI.ClearPassword();
-                        PopupBorder.Visibility = Visibility.Visible;
-                        PasswordUI.Visibility = Visibility.Visible;
-                    }
-                    else
-                    {
-                        pdfViewControl = passwordViewer;
-                        LoadDocument();
-                        FileChangeEvent?.Invoke(null, EventArgs.Empty);
-                    }
+                passwordViewer = new PDFViewControl();
+                passwordViewer.PDFView.InitDocument(filePath);
+                if (passwordViewer.PDFView.Document == null)
+                {
+                    MessageBox.Show("Open File Failed");
+                    return;
                 }
-            }
-            catch (Exception ex)
-            {
 
+                if (passwordViewer.PDFView.Document.IsLocked)
+                {
+                    PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " password encrypted.");
+                    PasswordUI.ClearPassword();
+                    PopupBorder.Visibility = Visibility.Visible;
+                    PasswordUI.Visibility = Visibility.Visible;
+                }
+                else
+                {
+                    pdfViewControl = passwordViewer;
+                    LoadDocument();
+                    FileChangeEvent?.Invoke(null, EventArgs.Empty);
+                }
             }
         }
 

+ 13 - 18
Demo/Examples/Viewer/App.xaml.cs

@@ -11,20 +11,21 @@ namespace Viewer
     {
         public string key = string.Empty;
         public string secret = string.Empty;
-        public SDKLicenseHelper() {
+        public SDKLicenseHelper()
+        {
 
             string sdkLicensePath = "license_key_win.xml";
             Assembly assembly = Assembly.GetExecutingAssembly();
             XmlDocument xmlDocument = new XmlDocument();
             xmlDocument.Load(sdkLicensePath);
             var node = xmlDocument.SelectSingleNode("License");
-            if (node != null )
+            if (node != null)
             {
                 key = node.Attributes["key"].Value;
                 secret = node.Attributes["secret"].Value;
             }
         }
-        
+
     }
 
     /// <summary>
@@ -43,22 +44,16 @@ namespace Viewer
         private static bool LicenseVerify()
         {
             bool result = false;
-            try
-            {
-                result = CPDFSDKVerifier.LoadNativeLibrary();
-                if (!result)
-                    return false;
-            }
-            catch
-            {}
+
+            result = CPDFSDKVerifier.LoadNativeLibrary();
+            if (!result)
+                return false;
+
             SDKLicenseHelper sdkLicenseHelper = new SDKLicenseHelper();
-            try
-            {
-                LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(sdkLicenseHelper.key, sdkLicenseHelper.secret);
-                if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
-                    return false;
-            }
-            catch { }
+
+            LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(sdkLicenseHelper.key, sdkLicenseHelper.secret);
+            if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
+                return false;
             return result;
         }
     }

+ 66 - 93
Demo/Examples/Viewer/MainWindow.xaml.cs

@@ -270,75 +270,63 @@ namespace Viewer
         {
             if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
             {
-                try
+                CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
+                if (pdfDoc.WriteToLoadedPath())
                 {
-                    CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
-                    if (pdfDoc.WriteToLoadedPath())
-                    {
-                        pdfViewControl.PDFView.UndoManager.CanSave = false;
-                        return;
-                    }
+                    pdfViewControl.PDFView.UndoManager.CanSave = false;
+                    return;
+                }
 
-                    SaveFileDialog saveDialog = new SaveFileDialog();
-                    saveDialog.Filter = "(*.pdf)|*.pdf";
-                    saveDialog.DefaultExt = ".pdf";
-                    saveDialog.OverwritePrompt = true;
+                SaveFileDialog saveDialog = new SaveFileDialog();
+                saveDialog.Filter = "(*.pdf)|*.pdf";
+                saveDialog.DefaultExt = ".pdf";
+                saveDialog.OverwritePrompt = true;
 
-                    if (saveDialog.ShowDialog() == true)
+                if (saveDialog.ShowDialog() == true)
+                {
+                    if (pdfDoc.WriteToFilePath(saveDialog.FileName))
                     {
-                        if (pdfDoc.WriteToFilePath(saveDialog.FileName))
-                        {
-                            pdfViewControl.PDFView.UndoManager.CanSave = false;
-                        }
+                        pdfViewControl.PDFView.UndoManager.CanSave = false;
                     }
                 }
-                catch (Exception ex)
-                {
-                }
             }
         }
 
         private void OpenFile_Click(object sender, RoutedEventArgs e)
         {
-            try
+            string filePath = CommonHelper.GetFilePathOrEmpty();
+            if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
             {
-                string filePath = CommonHelper.GetFilePathOrEmpty();
-                if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
+                if (pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
                 {
-                    if (pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
-                    {
-                        string oldFilePath = pdfViewControl.PDFView.Document.FilePath;
-                        if (oldFilePath.ToLower() == filePath.ToLower())
-                        {
-                            return;
-                        }
-                    }
-
-                    passwordViewer = new PDFViewControl();
-                    passwordViewer.PDFView.InitDocument(filePath);
-                    if (passwordViewer.PDFView.Document == null)
+                    string oldFilePath = pdfViewControl.PDFView.Document.FilePath;
+                    if (oldFilePath.ToLower() == filePath.ToLower())
                     {
-                        MessageBox.Show("Open File Failed");
                         return;
                     }
+                }
 
-                    if (passwordViewer.PDFView.Document.IsLocked)
-                    {
-                        PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " password encrypted.");
-                        PasswordUI.ClearPassword();
-                        PopupBorder.Visibility = Visibility.Visible;
-                        PasswordUI.Visibility = Visibility.Visible;
-                    }
-                    else
-                    {
-                        pdfViewControl = passwordViewer;
-                        LoadDocument();
-                    }
+                passwordViewer = new PDFViewControl();
+                passwordViewer.PDFView.InitDocument(filePath);
+                if (passwordViewer.PDFView.Document == null)
+                {
+                    MessageBox.Show("Open File Failed");
+                    return;
+                }
+
+                if (passwordViewer.PDFView.Document.IsLocked)
+                {
+                    PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " password encrypted.");
+                    PasswordUI.ClearPassword();
+                    PopupBorder.Visibility = Visibility.Visible;
+                    PasswordUI.Visibility = Visibility.Visible;
+                }
+                else
+                {
+                    pdfViewControl = passwordViewer;
+                    LoadDocument();
                 }
             }
-            catch (Exception ex)
-            { 
-            } 
         }
 
         private void SaveFileBtn_Click(object sender, RoutedEventArgs e)
@@ -357,64 +345,49 @@ namespace Viewer
             {
                 string choosePath = folderDialog.SelectedPath;
                 string openPath = choosePath;
-                try
-                {
-                    Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
+                Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
 
-                    if (imageDict != null && imageDict.Count > 0)
+                if (imageDict != null && imageDict.Count > 0)
+                {
+                    foreach (int pageIndex in imageDict.Keys)
                     {
-                        foreach (int pageIndex in imageDict.Keys)
+                        List<Bitmap> imageList = imageDict[pageIndex];
+                        foreach (Bitmap image in imageList)
                         {
-                            List<Bitmap> imageList = imageDict[pageIndex];
-                            foreach (Bitmap image in imageList)
-                            {
-                                string savePath = Path.Combine(choosePath, Guid.NewGuid() + ".jpg");
-                                image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
-                                openPath = savePath;
-                            }
+                            string savePath = Path.Combine(choosePath, Guid.NewGuid() + ".jpg");
+                            image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
+                            openPath = savePath;
                         }
                     }
-                    Process.Start("explorer", "/select,\"" + openPath + "\"");
                 }
-                catch (Exception ex)
-                {
-
-                }
-
+                Process.Start("explorer", "/select,\"" + openPath + "\"");
             }
         }
 
         private void CopyImage_Click(object sender, RoutedEventArgs e)
         {
-            try
-            {
-                Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
+            Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
 
-                if (imageDict != null && imageDict.Count > 0)
+            if (imageDict != null && imageDict.Count > 0)
+            {
+                foreach (int pageIndex in imageDict.Keys)
                 {
-                    foreach (int pageIndex in imageDict.Keys)
+                    List<Bitmap> imageList = imageDict[pageIndex];
+                    foreach (Bitmap image in imageList)
                     {
-                        List<Bitmap> imageList = imageDict[pageIndex];
-                        foreach (Bitmap image in imageList)
-                        {
-                            MemoryStream ms = new MemoryStream();
-                            image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
-                            BitmapImage imageData = new BitmapImage();
-                            imageData.BeginInit();
-                            imageData.StreamSource = ms;
-                            imageData.CacheOption = BitmapCacheOption.OnLoad;
-                            imageData.EndInit();
-                            imageData.Freeze();
-                            Clipboard.SetImage(imageData);
-                            break;
-                        }
+                        MemoryStream ms = new MemoryStream();
+                        image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
+                        BitmapImage imageData = new BitmapImage();
+                        imageData.BeginInit();
+                        imageData.StreamSource = ms;
+                        imageData.CacheOption = BitmapCacheOption.OnLoad;
+                        imageData.EndInit();
+                        imageData.Freeze();
+                        Clipboard.SetImage(imageData);
+                        break;
                     }
                 }
             }
-            catch (Exception ex)
-            {
-
-            }
         }
 
         private void PDFView_AnnotCommandHandler(object sender, AnnotCommandArgs e)
@@ -561,9 +534,9 @@ namespace Viewer
         }
 
         #endregion
-        
+
         #region Close Window
-        
+
         protected override void OnClosing(CancelEventArgs e)
         {
             if (pdfViewControl.PDFView.UndoManager.CanSave)