Przeglądaj źródła

Merge branch 'develop_PDFReaderProNew' of git.kdan.cc:Mac_PDF/PDF_Office into develop_PDFReaderProNew

liujiajie 6 miesięcy temu
rodzic
commit
a7dcd3e97c
42 zmienionych plików z 498 dodań i 303 usunięć
  1. 18 9
      PDF Office/PDF Master/AppDelegate.swift
  2. 2 3
      PDF Office/PDF Master/Base.lproj/Main.storyboard
  3. 2 0
      PDF Office/PDF Master/Class/ChromiumTabs/src/Tab Strip/CTTabStripController.m
  4. 1 1
      PDF Office/PDF Master/Class/ChromiumTabs/src/Tab/CTTabController.m
  5. 4 0
      PDF Office/PDF Master/Class/DigtalSignature/CPDFDigtalView/KMPDFDigitalSignViewController.swift
  6. 13 0
      PDF Office/PDF Master/Class/DigtalSignature/CPDFDigtalView/KMPDFDigitalSignViewController.xib
  7. 6 3
      PDF Office/PDF Master/Class/Document/KMMainDocument.swift
  8. 8 12
      PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/Model/KMQucikToolsModel.swift
  9. 1 1
      PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/View/KMQucikToolCollectionViewItem.swift
  10. 17 6
      PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+Action.swift
  11. 1 19
      PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+UI.swift
  12. 1 1
      PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController.swift
  13. 2 2
      PDF Office/PDF Master/Class/KMFileManager/KMFile/KMFile.swift
  14. 1 1
      PDF Office/PDF Master/Class/PDFTools/Convert/ExtractImage/Model/PDFConvertObject.swift
  15. 1 1
      PDF Office/PDF Master/Class/PDFTools/Print/Controller/KMPrintAccessoryController_OC.m
  16. 6 3
      PDF Office/PDF Master/Class/PDFTools/Print/KMPrintWindowController.swift
  17. 5 4
      PDF Office/PDF Master/Class/PDFTools/Print/Presenter/KMPrintPresenter.swift
  18. 1 0
      PDF Office/PDF Master/Class/PDFTools/Rate/KMRateWindowController.swift
  19. 27 3
      PDF Office/PDF Master/Class/PDFWindowController/MainWindowController/SKPresentationOptionsSheetController.swift
  20. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/CPDFListAnnotationNoteWindowController.swift
  21. 13 8
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Event.m
  22. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Annotation/KMAnnotationTool/KMBOTAAnnotationTool.swift
  23. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Annotation/KMAnnotationViewController.swift
  24. 2 2
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Annotation/View/KMAnnotationTableCellView.swift
  25. 9 0
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Outline.swift
  26. 11 0
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Search.swift
  27. 2 2
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Thumbnail.swift
  28. 16 7
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController.swift
  29. 6 2
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Thumbnail/Base/KMPDFThumbViewBaseController.swift
  30. 34 21
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMGeneralAnnotationViewController.swift
  31. 9 0
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/View/KMFreeTextStylesViewController/KMFreeTextStylesViewController.m
  32. 8 6
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/WindowController/KMAnnotationFontWindowController.swift
  33. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureAnnotationViewController.m
  34. 3 3
      PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarItemView.swift
  35. 20 125
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift
  36. 4 1
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift
  37. 86 40
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift
  38. 39 13
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift
  39. 5 0
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/Model/KMMainModel.swift
  40. 1 0
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/Views/KMPageNumberDisplayView/KMPageNumberDisplayView.swift
  41. 2 0
      PDF Office/PDF Master/Class/Purchase/DMG/Verification/KMVerificationWindowController.h
  42. 107 0
      PDF Office/PDF Master/Class/Purchase/DMG/Verification/KMVerificationWindowController.m

+ 18 - 9
PDF Office/PDF Master/AppDelegate.swift

@@ -10,6 +10,9 @@ import UserNotifications
 
 @main
 class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate{
+    
+    var rateWindowVC: KMRateWindowController!
+    
     func applicationWillFinishLaunching(_ notification: Notification) {
 #if VERSION_FREE
 #if VERSION_DMG
@@ -202,8 +205,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate{
     
     //MARK: iRateDelegate
     func iRateUserDidDeclineToRateApp() {
-        
+        KMVerificationWindowController.verificationFeedback()
     }
+    
     func iRateShouldPromptForRating() -> Bool {
         let notShow: Bool = UserDefaults.standard.bool(forKey: "kUserHaveClickRateUsKey")
         if !notShow {
@@ -211,13 +215,16 @@ class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate{
             UserDefaults.standard.synchronize()
             NotificationCenter.default.post(name: Notification.Name(rawValue: "kUserHaveClickRateUsNotification"), object: self)
         }
-        let rate = KMRateWindowController()
-        let window = NSWindow.currentWindow()
-//        window.km_beginSheet(windowC: rate)
-        rate.closeBlock = { wc in
-            window.km_quick_endSheet()
+        
+        self.rateWindowVC = KMRateWindowController.init(windowNibName: "KMRateWindowController")
+        
+        self.rateWindowVC.closeBlock = { wc in
+
+        }
+        self.rateWindowVC.closeBlock = { wc in
+            
         }
-        rate.showWindow(nil)
+        self.rateWindowVC.showWindow(nil)
         return false
     }
     
@@ -880,11 +887,13 @@ extension AppDelegate : SUUpdaterDelegate {
     }
     
     func feedURLString(for updater: SUUpdater) -> String? {
+        var hostURL = "https://www.pdfreaderpro.com/downloads/"
 #if DEBUG
-        return "http://test-pdf-pro.kdan.cn:3021/downloads/pdfmasterprocast.xml"
+        hostURL = "http://test-pdf-pro.kdan.cn:3021/downloads/"
 #else
-        return "https://www.pdfreaderpro.com/downloads/pdfmasterprocast.xml"
+        hostURL = "https://www.pdfreaderpro.com/downloads/"
 #endif
+        return hostURL+NSLocalizedString("pdfreaderprocast.xml", comment: "")
     }
     
     func updaterShouldPromptForPermissionToCheck(forUpdates updater: SUUpdater) -> Bool {

+ 2 - 3
PDF Office/PDF Master/Base.lproj/Main.storyboard

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <scenes>
@@ -484,7 +484,6 @@
                                             <string key="keyEquivalent" base64-UTF8="YES">
 CA
 </string>
-                                            <modifierMask key="keyEquivalentModifierMask"/>
                                             <connections>
                                                 <action selector="delete:" target="Ady-hI-5gd" id="0Mk-Ml-PaM"/>
                                             </connections>

+ 2 - 0
PDF Office/PDF Master/Class/ChromiumTabs/src/Tab Strip/CTTabStripController.m

@@ -1047,6 +1047,8 @@ const NSTimeInterval kAnimationDuration = 0.125;
 		titleString = contents.title;
 	if (!titleString || ![titleString length])
 		titleString = L10n(@"New Tab");
+    
+    titleString = titleString.stringByDeletingPathExtension;
 	[tab setTitle:titleString];
 }
 

+ 1 - 1
PDF Office/PDF Master/Class/ChromiumTabs/src/Tab/CTTabController.m

@@ -56,7 +56,7 @@ static NSString* const kBrowserThemeDidChangeNotification =
 // images). The active tab width includes the close button width.
 + (CGFloat)minTabWidth { return 40; }
 + (CGFloat)minActiveTabWidth { return 40; }
-+ (CGFloat)maxTabWidth { return 150; }
++ (CGFloat)maxTabWidth { return 200; }
 + (CGFloat)miniTabWidth { return 40; }
 + (CGFloat)appTabWidth { return 66; }
 + (CGFloat)homeTabWidth { return 120; }

+ 4 - 0
PDF Office/PDF Master/Class/DigtalSignature/CPDFDigtalView/KMPDFDigitalSignViewController.swift

@@ -256,6 +256,10 @@ class KMPDFDigitalSignViewController: NSViewController, CPDFViewDelegate {
         self.pdfView.go(toPageIndex: self.currentPageIndex, animated: true)
     }
     
+    func setCurrentPageIndex(_ currentPageIndex: Int) {
+        self.pdfView.go(toPageIndex: currentPageIndex, animated: false)
+    }
+    
     func pdfViewCurrentPageDidChanged(_ pdfView: CPDFView!) {
         let fileName = pdfView.document.documentURL.deletingPathExtension().lastPathComponent
         let title = String(format: "%@ (page %ld / %ld)", fileName, pdfView.currentPageIndex+1, pdfView.document.pageCount)

+ 13 - 0
PDF Office/PDF Master/Class/DigtalSignature/CPDFDigtalView/KMPDFDigitalSignViewController.xib

@@ -32,6 +32,16 @@
                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="SJ2-pS-M3B">
                     <rect key="frame" x="0.0" y="0.0" width="572" height="387"/>
                     <subviews>
+                        <button translatesAutoresizingMaskIntoConstraints="NO" id="DXG-U6-4uT">
+                            <rect key="frame" x="0.0" y="299" width="572" height="88"/>
+                            <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" imagePosition="left" inset="2" id="Fkr-1Y-hA9">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <constraints>
+                                <constraint firstAttribute="height" constant="88" id="gOp-Fc-09h"/>
+                            </constraints>
+                        </button>
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="0a0-Fd-gka">
                             <rect key="frame" x="0.0" y="343" width="572" height="44"/>
                             <subviews>
@@ -139,11 +149,14 @@
                     </subviews>
                     <constraints>
                         <constraint firstItem="0a0-Fd-gka" firstAttribute="top" secondItem="SJ2-pS-M3B" secondAttribute="top" id="55g-wO-0OT"/>
+                        <constraint firstItem="DXG-U6-4uT" firstAttribute="top" secondItem="SJ2-pS-M3B" secondAttribute="top" id="85x-iQ-2Rx"/>
                         <constraint firstAttribute="bottom" secondItem="Zqz-md-wWY" secondAttribute="bottom" id="FUC-Kx-gTD"/>
                         <constraint firstAttribute="trailing" secondItem="0a0-Fd-gka" secondAttribute="trailing" id="G1W-22-Qz7"/>
+                        <constraint firstAttribute="trailing" secondItem="DXG-U6-4uT" secondAttribute="trailing" id="LTi-Nv-1wb"/>
                         <constraint firstAttribute="trailing" secondItem="Zqz-md-wWY" secondAttribute="trailing" id="O3j-vR-LrR"/>
                         <constraint firstItem="LSe-Oi-yzJ" firstAttribute="top" secondItem="0a0-Fd-gka" secondAttribute="bottom" id="T4w-1s-hJl"/>
                         <constraint firstItem="Zqz-md-wWY" firstAttribute="top" secondItem="0a0-Fd-gka" secondAttribute="bottom" constant="44" id="TVB-8H-a7j"/>
+                        <constraint firstItem="DXG-U6-4uT" firstAttribute="leading" secondItem="SJ2-pS-M3B" secondAttribute="leading" id="U7y-2w-BWo"/>
                         <constraint firstItem="0a0-Fd-gka" firstAttribute="leading" secondItem="SJ2-pS-M3B" secondAttribute="leading" id="Xr7-mF-Gp6"/>
                         <constraint firstAttribute="trailing" secondItem="LSe-Oi-yzJ" secondAttribute="trailing" id="Yh1-Yn-0lm"/>
                         <constraint firstItem="LSe-Oi-yzJ" firstAttribute="leading" secondItem="SJ2-pS-M3B" secondAttribute="leading" id="gFX-ft-SN3"/>

+ 6 - 3
PDF Office/PDF Master/Class/Document/KMMainDocument.swift

@@ -592,7 +592,7 @@ typealias KMMainDocumentCloudUploadHanddler = (@escaping(Bool, String)->()) -> (
             
             let dic = notification.object as? NSDictionary
             if dic?["object"] is CPDFAnnotation {
-                let annotation : CPDFAnnotation = dic?["object"] as? CPDFAnnotation ?? CPDFAnnotation()
+                guard let annotation = dic?["object"] as? CPDFAnnotation else { return }
                 document = annotation.page.document
 
             } else if dic?["object"] is CPDFListView {
@@ -817,6 +817,7 @@ typealias KMMainDocumentCloudUploadHanddler = (@escaping(Bool, String)->()) -> (
         self.mainViewController?.removeOwnerPassword()
     }
     @IBAction func printPDFDocument(_ sender: Any?) {
+        self.mainViewController?.saveDocument()
         KMPrintWindowController.showNewPrintWindowControll(inputDocument: self.mainViewController?.document, inputPageRange: KMPrintPageRange())
     }
     @IBAction func performFindPanelAction(_ sender: Any?) {
@@ -977,9 +978,9 @@ typealias KMMainDocumentCloudUploadHanddler = (@escaping(Bool, String)->()) -> (
             return
         }
         var success = true
-        NotificationCenter.default.post(name: Notification.Name(rawValue: "kCPDFDocumentDidBeginWriteNotification"), object: self)
         if !self.isHome {
             if mainViewController != nil {
+                mainViewController?.savePdfAlertView()
                 if mainViewController?.document != nil {
                     self.mainViewController?.commitEditingIfNeed()
                     
@@ -1018,7 +1019,9 @@ typealias KMMainDocumentCloudUploadHanddler = (@escaping(Bool, String)->()) -> (
         if success && isNewCreated && NSDocument.SaveOperationType.saveAsOperation == saveOperation {
             isNewCreated = false
         }
-        NotificationCenter.default.post(name: Notification.Name(rawValue: "kCPDFDocumentDidEndWriteNotification"), object: self)
+        if mainViewController != nil {
+            mainViewController?.savePdfFinishAlertView()
+        }
     }
     
     private func _km_saveForWatermark(openAccessoryView: Bool = true, subscribeDidClick: (()->Void)? = nil, callback:@escaping (_ needSave: Bool, _ param: Any...)->Void) {

+ 8 - 12
PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/Model/KMQucikToolsModel.swift

@@ -21,20 +21,16 @@ class KMQucikToolsModel: NSObject {
     }
     
     static func showType() -> [DataNavigationViewButtonActionType] {
-        if UserDefaults.standard.object(forKey: "kQucikToolsShowType") != nil {
-            let array: [NSNumber] = UserDefaults.standard.object(forKey: "kQucikToolsShowType") as! [NSNumber]
-            if array.count != 0 {
-                var types: [DataNavigationViewButtonActionType] = []
-                for index in array {
-                    types.append(DataNavigationViewButtonActionType(rawValue: Int(truncating: index))!)
-                }
-                return types
-            } else {
-                return []
-            }
-        } else {
+        guard let array = UserDefaults.standard.array(forKey: "kQucikToolsShowType") as? [NSNumber], !array.isEmpty else {
             return self.allType()
         }
+        
+        return array.compactMap { index in
+            guard let type = DataNavigationViewButtonActionType(rawValue: index.intValue) else {
+                return nil
+            }
+            return type
+        }
     }
     
     static func hiddenType() -> [DataNavigationViewButtonActionType] {

+ 1 - 1
PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/View/KMQucikToolCollectionViewItem.swift

@@ -79,7 +79,7 @@ class KMQucikToolCollectionViewItem: NSCollectionViewItem {
         self.removeBox.borderColor = KMAppearance.Layout.w70Color()
         self.removeBox.borderWidth = 1.0
         
-        self.removeButton.title = "+" + NSLocalizedString("Remove", comment: "")
+        self.removeButton.title = "-" + NSLocalizedString("Remove", comment: "")
         self.removeButton.contentTintColor = KMAppearance.Layout.w0Color()
         self.removeButton.backgroundColor(KMAppearance.Status.preColor())
         

+ 17 - 6
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+Action.swift

@@ -610,8 +610,18 @@ extension KMHomeViewController {
         } else {
         }
         if success {
-            NSDocumentController.shared.km_safe_openDocument(withContentsOf: URL(fileURLWithPath: path), display: true) { _, _, _ in
-                
+            NSDocumentController.shared.km_safe_openDocument(withContentsOf: URL(fileURLWithPath: path), display: true) { document, isOpened, error in
+                if error != nil {
+                    NSApp.presentError(error!)
+                } else {
+                    if FileManager.default.fileExists(atPath: filePath) {
+                        try? FileManager.default.removeItem(atPath: filePath)
+                    }
+                    if document is KMMainDocument {
+                        let newDocument = document
+                        (newDocument as! KMMainDocument).isNewCreated = true
+                    }
+                }
             }
         }
     }
@@ -1995,16 +2005,17 @@ extension KMHomeViewController {
 
 extension KMHomeViewController {    
     @IBAction func menuItemAction_showForwardTagPage(_ sender: Any) {
-        (self.myDocument as! KMMainDocument).browser.selectPreviousTab()
+        (self.myDocument as? KMMainDocument)?.browser.selectPreviousTab()
     }
     
     @IBAction func menuItemAction_showNextTagPage(_ sender: Any) {
-        (self.myDocument as! KMMainDocument).browser.selectNextTab()
+        (self.myDocument as? KMMainDocument)?.browser.selectNextTab()
     }
     
     @IBAction func menuItemAction_newTagPageToNewWindow(_ sender: Any) {
-        let browser = (self.myDocument as! KMMainDocument).browser
-        ((browser as! KMBrowser).windowController as? KMBrowserWindowController)?.openNewWindow(sender)
+        if let browser = (self.myDocument as? KMMainDocument)?.browser {
+            ((browser as! KMBrowser).windowController as? KMBrowserWindowController)?.openNewWindow(sender)
+        }
     }
     
     @IBAction func menuItemAction_mergeAllWindow(_ sender: Any) {

+ 1 - 19
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+UI.swift

@@ -82,25 +82,7 @@ extension KMHomeViewController {
     }
     
     func showSecurityWindow() {
-//        Task { @MainActor in
-//            #if VERSION_DMG
-//            if await (KMLightMemberManager.manager.canUseAdvanced() == false) {
-//                let _ = KMComparativeTableViewController.show(window: self.view.window!, .merge)
-//                return
-//            }
-//            #endif
-//
-//            if await (KMLightMemberManager.manager.canPayFunction() == false) {
-//                let _ = KMSubscribeWaterMarkWindowController.show(window: self.view.window!, isContinue: true) { isSubscribeSuccess, isWaterMarkExport, isClose in
-//                    if (isClose) {
-//                        return
-//                    }
-//                    self.km_secure_openPanel_security(limit: true)
-//                }
-//                return
-//            }
-//            self.km_secure_openPanel_security()
-//        }
+
     }
     
     func km_secure_openPanel_security(limit: Bool = false) {

+ 1 - 1
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController.swift

@@ -76,7 +76,7 @@ import Cocoa
     var homeWindowController : MainWindowController!
     
     var isShowQuickTour: Bool = false
-    var myDocument: NSDocument?
+    weak var myDocument: NSDocument?
     var currentWindowController: NSWindowController?
     var homeState: KMHomeToolState = .Home
     

+ 2 - 2
PDF Office/PDF Master/Class/KMFileManager/KMFile/KMFile.swift

@@ -18,7 +18,7 @@ class KMFile: NSObject {
     var url: URL?
     
     var showPath: String = ""
-    var pdfDocument: CPDFDocument?
+//    var pdfDocument: CPDFDocument?
     var systemPDFDocument: PDFDocument?
     var password: String = ""
     var isLocked: Bool = false
@@ -83,7 +83,7 @@ class KMFile: NSObject {
                 
                 self.image = image
                 self.info = info
-                self.pdfDocument = document
+//                self.pdfDocument = document
                 self.isLocked = ((document?.isLocked) != nil)
                 self.showPath = string.description
             }

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Convert/ExtractImage/Model/PDFConvertObject.swift

@@ -51,7 +51,7 @@ class PDFConvertObject: NSObject {
         self.delegate?.PDFConvertObjectDidEndConversion?(self, error: nil)
     }
     func imageNumberSuffix(_ imageIndex: Int) -> String {
-        let indexString = "(imageIndex)"
+        let indexString = String(format: "%d", imageIndex)
         var suffixString = ""
         if suffix > indexString.count {
             for _ in 0..<(suffix - indexString.count) {

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Print/Controller/KMPrintAccessoryController_OC.m

@@ -84,7 +84,7 @@
 }
 
 - (NSString *)title {
-    return NSLocalizedString(@"PrintAccessoryView", "");
+    return [[NSDocumentController sharedDocumentController] displayNameForType:@"com.adobe.pdf"];
 }
 
 - (BOOL)autoRotate {

+ 6 - 3
PDF Office/PDF Master/Class/PDFTools/Print/KMPrintWindowController.swift

@@ -258,9 +258,11 @@ extension KMPrintWindowController {
     
     static func showPrintWindowControll(inputData: URL?, inputDocument: AnyObject?, inputType: DataNavigationViewButtonActionType = .Print, inputPageRange: KMPrintPageRange) {
         var document: PDFDocument?
-        let filePath = KMPrintPresenter.fetchSaveFilePath("")
+        var filePath = ""
+        
         var password: String = ""
         if inputDocument != nil {
+            filePath = KMPrintPresenter.fetchSaveFilePath(fileName: inputDocument?.documentURL?.path.lastPathComponent ?? "text.pdf")
 //            if inputDocument != nil {
             if inputDocument is CPDFDocument {
                 let success = inputDocument?.writeDecrypt(to: URL(fileURLWithPath: filePath))
@@ -274,6 +276,7 @@ extension KMPrintWindowController {
         }
 
         if inputData != nil {
+            filePath = KMPrintPresenter.fetchSaveFilePath(fileName: inputData?.path.lastPathComponent ?? "text.pdf")
             document = PDFDocument.init(url: inputData!)!
         }
         
@@ -284,7 +287,7 @@ extension KMPrintWindowController {
                 inputPageRange.selectPages.count != 0) {
                 
                 let printPresent = KMPrintPresenter()
-                let filePath = KMPrintPresenter.fetchSaveFilePath("")
+//                let filePath = KMPrintPresenter.fetchSaveFilePath("")
                 let paperSize = (document?.page(at: 0)?.bounds(for: .cropBox).size) ?? CGSizeZero
                 let context: CGContext = printPresent.createContext(filePath, paperSize)
                 var pages: [PDFPage] = []
@@ -372,7 +375,7 @@ extension KMPrintWindowController {
             let controller = KMPrintAccessoryController_OC(nibName: "KMPrintAccessoryController_OC", bundle: nil)
             printOperation.printPanel.addAccessoryController(controller)
             
-            printOperation.runModal(for: NSApplication.shared.mainWindow!, delegate: self, didRun: nil, contextInfo: nil)
+            printOperation.runModal(for: NSWindow.currentWindow(), delegate: self, didRun: nil, contextInfo: nil)
         }
     }
     

+ 5 - 4
PDF Office/PDF Master/Class/PDFTools/Print/Presenter/KMPrintPresenter.swift

@@ -100,7 +100,7 @@ extension KMPrintPresenter: KMPrintPresenterDocument {
         //获取每张纸的page
         let drawPages: [KMPrintDrawPage] = self.fetchDrawPages(paperSize, printModel.page, paperCount, pageOfPaperCount, pages)
         //导出地址
-        let filePath = KMPrintPresenter.fetchSaveFilePath(toFilePath)
+        let filePath = KMPrintPresenter.fetchSaveFilePath(filePath:toFilePath ?? "")
         
         
         //方法一
@@ -261,10 +261,11 @@ extension KMPrintPresenter: KMPrintPresenterDocument {
      @param contentType annoation类型
      @param selectPages 当type 为custom时  传入选中page的下标
      */
-    static func fetchSaveFilePath(_ filePath: String?) -> String {
-        var saveFilePath = filePath ?? ""
+    static func fetchSaveFilePath(filePath: String = "", fileName: String = "test2.pdf") -> String {
+        var saveFilePath = filePath
+        var saveFileName = fileName 
         if saveFilePath.count == 0 {
-            saveFilePath = NSTemporaryDirectory() + "/PDFReaderProTest/test2.pdf"
+            saveFilePath = NSTemporaryDirectory() + "PDFReaderProTest/" + saveFileName
         }
         
         if !FileManager.default.fileExists(atPath: NSTemporaryDirectory() + "/PDFReaderProTest") {

+ 1 - 0
PDF Office/PDF Master/Class/PDFTools/Rate/KMRateWindowController.swift

@@ -78,6 +78,7 @@ class KMRateWindowController: NSWindowController, NSWindowDelegate{
     }
     
     override func close() {
+        super.close()
         if (self.closeBlock != nil) {
             closeBlock!(self)
         }

+ 27 - 3
PDF Office/PDF Master/Class/PDFWindowController/MainWindowController/SKPresentationOptionsSheetController.swift

@@ -183,7 +183,7 @@ class SKPresentationOptionsSheetController: KMBaseWindowController {
         self.effectPopUpButton.target = self
         self.effectPopUpButton.action = #selector(effectButtonAction)
         
-        self.durationTF.formatter = NumberFormatter()
+//        self.durationTF.formatter = NumberFormatter()
         self.durationTF.delegate = self
         
         self.screeBtn.target = self
@@ -577,11 +577,35 @@ class SKPresentationOptionsSheetController: KMBaseWindowController {
 extension SKPresentationOptionsSheetController: NSTextFieldDelegate {
     func controlTextDidChange(_ obj: Notification) {
         if self.durationTF.isEqual(to: obj.object) {
-            self.durationSlider.floatValue = self.durationTF.floatValue
+//            self.durationSlider.floatValue = self.durationTF.floatValue
             // 更新数据
-            self._updateInfo(key: KMDurationName, value: self.durationTF.floatValue)
+//            self._updateInfo(key: KMDurationName, value: self.durationTF.floatValue)
         }
     }
+    func controlTextDidEndEditing(_ obj: Notification) {
+        if self.durationTF.isEqual(to: obj.object) {
+            if checkString(str: self.durationTF.stringValue) {
+                self.durationSlider.floatValue = self.durationTF.floatValue
+                // 更新数据
+                self._updateInfo(key: KMDurationName, value: self.durationTF.floatValue)
+            }else{
+                self.durationTF.stringValue = "1.0"
+            }
+        }
+    }
+//    func controlTextDidBeginEditing(_ obj: Notification) {
+//        if self.durationTF.isEqual(to: obj.object) {
+//            
+//        }
+//    }
+    func checkString(str: String) -> Bool {
+        let reg = "^[1-9]d*.d*|0.d*[1-9]d*|0?.0+|0$"
+        let pre = NSPredicate(format: "SELF MATCHES %@", reg)
+        if pre.evaluate(with: str) {
+            return true
+        }
+        return false
+    }
 }
 
 // MARK: - NSWindowDelegate

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/CPDFListAnnotationNoteWindowController.swift

@@ -166,7 +166,7 @@ class CPDFListAnnotationNoteWindowController: KMBaseWindowController {
             } else if keyPath == "markupText" {
                 synchronizeWindowTitleWithDocumentName()
                 if let note = self.note as? CPDFMarkupAnnotation {
-                    contentTextView.string = note.markupText()
+                    contentTextView.string = note.markupText() ?? ""
                 }
             }
         } else {

+ 13 - 8
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Event.m

@@ -679,10 +679,10 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
             {
                 subMenu = [[NSMenu alloc]init];
                 
-                NSMenuItem * rightItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Rotate Right", @"PDFListView") action:@selector(rotateRightStampAnnotation:) keyEquivalent:@""];
                 NSMenuItem * leftItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Rotate Left", @"PDFListView") action:@selector(rotateLeftStampAnnotation:) keyEquivalent:@""];
-                [subMenu addItem:rightItem];
+                NSMenuItem * rightItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Rotate Right", @"PDFListView") action:@selector(rotateRightStampAnnotation:) keyEquivalent:@""];
                 [subMenu addItem:leftItem];
+                [subMenu addItem:rightItem];
                 rotateItem.submenu = subMenu;
             }
             
@@ -830,9 +830,9 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     if ([self.activeAnnotation isKindOfClass:[CPDFListStampAnnotation class]]) {
         CPDFListStampAnnotation *anno = (CPDFListStampAnnotation *)self.activeAnnotation;
         if (anno.pImage != nil) {
-            [self rotateImageStampAnnotation:anno rotateAngle:-90];
+            [self rotateImageStampAnnotation:anno rotateAngle:90];
         } else {
-            [self rotateLeftForStampAnnotation:self.activeAnnotation];
+            [self rotateRightForStampAnnotation:self.activeAnnotation];
         }
     }
 }
@@ -841,9 +841,9 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     if ([self.activeAnnotation isKindOfClass:[CPDFListStampAnnotation class]]) {
         CPDFListStampAnnotation *anno = (CPDFListStampAnnotation *)self.activeAnnotation;
         if (anno.pImage != nil) {
-            [self rotateImageStampAnnotation:anno rotateAngle:90];
+            [self rotateImageStampAnnotation:anno rotateAngle:-90];
         } else {
-            [self rotateRightForStampAnnotation:self.activeAnnotation];
+            [self rotateLeftForStampAnnotation:self.activeAnnotation];
         }
     }
 }
@@ -4986,10 +4986,10 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     }];
 }
 
-- (void)menuItemClick_StampExport: (NSMenuItem *)sender{
+- (void)menuItemClick_StampExport: (NSMenuItem *)sender {
+    NSImage *image = nil;
     if ([self.activeAnnotation isKindOfClass:[CPDFStampAnnotation class]]) {
         CPDFStampAnnotation *annotation = (CPDFStampAnnotation *)self.activeAnnotation;
-        NSImage *image = nil;
         if ([self.activeAnnotation isKindOfClass:[KMAnnotationStamp class]]) {
             image = annotation.stampImage;
         }
@@ -5005,6 +5005,11 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
             [[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationDefault];
             [image unlockFocus];
         }
+    } else if (self.currentSelection.selectionType == CPDFSelectionTypeImage) {
+        image = [self.document extractImageFromPage:self.currentSelection.page imageSelection:self.currentSelection];
+    }
+    
+    if (image) {
         NSData *data = [image TIFFRepresentation];
         NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:data];
         [imageRep setSize:[image size]];

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Annotation/KMAnnotationTool/KMBOTAAnnotationTool.swift

@@ -115,7 +115,7 @@ class KMBOTAAnnotationTool: NSObject {
         if annotation.contents != nil {
             contentString = annotation.contents
             if annotation.isKind(of: CPDFMarkupAnnotation.self) {
-                var markupString: String = (annotation as! CPDFMarkupAnnotation).markupText()
+                var markupString: String = (annotation as! CPDFMarkupAnnotation).markupText() ?? ""
                 contentString = contentString.replacingOccurrences(of: " ", with: "")
                 markupString = markupString.replacingOccurrences(of: " ", with: "")
                 

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Annotation/KMAnnotationViewController.swift

@@ -438,7 +438,7 @@ extension KMAnnotationViewController {
                     let item: CPDFMarkupAnnotation = annotationItem.annotation! as? CPDFMarkupAnnotation ?? CPDFMarkupAnnotation()
                     if item.markupText() != nil {
                         KMPrint(item.markupText() as Any)
-                        content = content + "\n" + item.markupText()
+                        content = content + "\n" + (item.markupText() ?? "")
                     }
 
                     let pasteBoard = NSPasteboard.general

+ 2 - 2
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Annotation/View/KMAnnotationTableCellView.swift

@@ -176,10 +176,10 @@ class KMAnnotationTableCellView: NSTableCellView {
         
         var contentString = annotation.contents
         if annotation.isKind(of: CPDFMarkupAnnotation.self) {
-            contentString = (annotation as! CPDFMarkupAnnotation).markupText()
+            contentString = (annotation as! CPDFMarkupAnnotation).markupText() ?? ""
         }
         if contentString != nil && contentString != "" {
-            if contentString!.count > 0 {
+            if contentString?.count ?? 0 > 0 {
                 let height = KMBOTAAnnotationTool.fetchTextHeight(string: contentString!, maxSize: NSSize(width: 188, height: 300))
                 self.contentBGHeightConst.constant = height + 8
             }

+ 9 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Outline.swift

@@ -410,6 +410,15 @@ extension KMLeftSideViewController {
             }
         }
     }
+    
+    public func refreshUIOfOutlineIfNeed() {
+        if self.type.methodType != .Outline {
+            return
+        }
+        Task { @MainActor in
+            self.tocOutlineView.reloadData()
+        }
+    }
 }
 
 // MARK: - Undo & Redo

+ 11 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Search.swift

@@ -139,6 +139,17 @@ extension KMLeftSideViewController {
         self.groupedFindTableView.tableColumn(withIdentifier: kPageColumnId)?.headerCell.title = KMLocalizedString("Page", "Table header title")
         (self.groupedFindTableView.tableColumn(withIdentifier: _kRelevanceColumnId)?.dataCell as? NSCell)?.isEnabled = false
     }
+    
+    public func refreshUIOfSeachListIfNeed() {
+        if self.type.methodType != .Search {
+            return
+        }
+        Task { @MainActor in
+            if self.searchField.stringValue.isEmpty == false {
+                self.search(self.searchField)
+            }
+        }
+    }
 }
 
 // MARK: - Menu

+ 2 - 2
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Thumbnail.swift

@@ -128,8 +128,8 @@ extension KMLeftSideViewController {
         self.thumbnailTableView.botaDelegate = self
         self.thumbnailTableView.menu?.delegate = self
         self.thumbnailTableView.registerForDraggedTypes([.localDraggedTypes, .fileURL,.string,.pdf])
-//        self.thumbnailTableView.registerForDraggedTypes(NSFilePromiseReceiver.readableDraggedTypes.map { NSPasteboard.PasteboardType($0) })
-//        self.thumbnailTableView.setDraggingSourceOperationMask(.every, forLocal: false)
+        self.thumbnailTableView.registerForDraggedTypes(NSFilePromiseReceiver.readableDraggedTypes.map { NSPasteboard.PasteboardType($0) })
+        self.thumbnailTableView.setDraggingSourceOperationMask(.every, forLocal: false)
     }
     
     func thumb_initDefalutValue() {

+ 16 - 7
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController.swift

@@ -609,6 +609,13 @@ class KMLeftSideViewController: KMSideViewController {
     }
     
     func displayTocViewAnimating(_ animate: Bool) {
+        if Thread.current.isMainThread {
+            self.tocOutlineView.reloadData()
+        } else {
+            Task { @MainActor in
+                self.tocOutlineView.reloadData()
+            }
+        }
         if let data = self.tocOutlineView.enclosingScrollView {
             self.replaceSideView(data, animate: animate)
         }
@@ -1324,7 +1331,7 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
                 let page = pages[i]
                 self.pdfDocument()?.insertPageObject(page, at: UInt(toPageIndex+i))
                 pageIndex += 1
-                self.listView?.go(toPageIndex: toPageIndex+i, animated: false)
+                self.listView?.go(toPageIndex: toPageIndex+i-1, animated: false)
             }
             self.layoutDocumentView()
             var deletepages: [CPDFPage] = []
@@ -1411,7 +1418,7 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
     func tableView(_ tableView: NSTableView, writeRowsWith rowIndexes: IndexSet, to pboard: NSPasteboard) -> Bool {
         if tableView.isEqual(to: self.thumbnailTableView) {
             let idx = rowIndexes.first ?? NSNotFound
-            if (idx != NSNotFound && self.isLocked()) {
+            if (idx != NSNotFound && self.isLocked() == false) {
                 let page = self.pdfDocument()?.page(at: UInt(idx))
                 var fileExt: String?
                 let tiffData = page?.PDFListViewTIFFData(for: page?.bounds(for: self.displayBox()) ?? .zero)
@@ -1518,11 +1525,13 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
             guard let last = rowIndexes.last, last < self.pageCount() else {
                 return
             }
+            //删除page时移除选中状态的annotation
+            self.listView?.activeAnnotations = []
             for idx in rowIndexes {
                 if let page = self.pdfDocument()?.page(at: UInt(idx)) {
-                    for anno in page.annotations {
-                        page.removeAnnotation(anno)
-                    }
+//                    for anno in page.annotations {
+//                        page.removeAnnotation(anno)
+//                    }
                     (self.listView?.undoManager?.prepare(withInvocationTarget: self) as AnyObject).insertPage(page, pageAt:  idx)
 //                    self.pdfDocument()?.removePage(at: IndexSet(integer: idx))
                 }
@@ -1849,12 +1858,12 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
             if let data = item as? String, data == Self.kOutlineRootBookmarkItem {
                 title = NSLocalizedString("Bookmarks", comment: "")
             } else if let ol = item as? CPDFOutline {
-                title = ol.label
+                title = ol.label ?? ""
                 if ol.actionType == .page {
                     pageLabel = "\((ol.destination?.pageIndex ?? 0) + 1)"
                 }
             } else if let bk = item as? CPDFBookmark {
-                title = bk.label
+                title = bk.label ?? ""
                 pageLabel = "\(bk.pageIndex + 1)"
             }
             

+ 6 - 2
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Thumbnail/Base/KMPDFThumbViewBaseController.swift

@@ -948,7 +948,7 @@ class KMPDFThumbViewBaseController: KMBaseViewController {
         if (item.sel == KMPDFThumbViewMenu.deleteSelector) {
             item_ = menu.addItem(withTitle: NSLocalizedString("Delete Page", comment: ""), action: KMPDFThumbViewMenu.deleteSelector, target: self)
             item_?.keyEquivalent = String(Unicode.Scalar(NSBackspaceCharacter)!)
-            item_?.keyEquivalentModifierMask = []
+            item_?.keyEquivalentModifierMask = [.command]
             if (!self.canDelete()) {
                 item_?.action = nil
             }
@@ -1010,7 +1010,11 @@ extension KMPDFThumbViewBaseController {
         if (KMPDFThumbViewMenu.containsSelector(sel: action)) {
             let row = self.thumbnailView.collectionView.selectionIndexes
             if (action != KMPDFThumbViewMenu.pasteSelector) {
-                return row.count > 0
+                if action == KMPDFThumbViewMenu.printSelector {
+                    return true
+                } else {
+                    return row.count > 0
+                }
             }
             
             // paste

+ 34 - 21
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMGeneralAnnotationViewController.swift

@@ -1718,10 +1718,22 @@ let KMColorPickerViewHeight: CGFloat = 64
         var fillColor = NSColor.clear
         var red: CGFloat = 0.0, green: CGFloat = 0.0, blue: CGFloat = 0.0, opacity: CGFloat = 0.0
 
-        if let fillColorPickerColor = fillColorPickerView.color {
-            annotationModel?.setColor(fillColorPickerColor)
+        if let borderColor = borderColorPickerView.color {
+            borderColor.usingColorSpaceName(.calibratedRGB)?.getRed(&red, green: &green, blue: &blue, alpha: &opacity)
+            let color = NSColor(calibratedRed: red, green: green, blue: blue, alpha: opacity)
+            fillColor = color
+        }
+
+        if annotationType == .freeText {
+            if let fillColorPickerColor = fillColorPickerView.color {
+                annotationModel?.setColor(fillColorPickerColor)
 //                annotationModel?.setOpacity(opacity)
+            }
+        } else {
+            annotationModel?.setColor(fillColor)
+            annotationModel?.setOpacity(opacity)
         }
+
         updateAnnotation(.color)
     }
     
@@ -2326,39 +2338,40 @@ let KMColorPickerViewHeight: CGFloat = 64
     }
     
     func annotationFontReload() {
-        DispatchQueue.global(qos: .default).async { [self] in
+        DispatchQueue.global(qos: .default).async { [weak self] in
+            guard let self = self else { return }
             let fonts = NSFontManager.shared.availableFontFamilies
             let menu = NSMenu()
             var selectedIndex = 0
             
             for (index, fontName) in fonts.enumerated() {
                 if let font = NSFont(name: fontName, size: 12.0) {
-                    let attributedString = NSAttributedString(string: fontName, attributes: [NSAttributedString.Key.font: font])
+                    let attributedString = NSAttributedString(string: fontName, attributes: [.font: font])
                     let item = NSMenuItem()
                     item.attributedTitle = attributedString
                     menu.addItem(item)
-                    
-                    if annotationType == .freeText || annotationType == .signText || annotationType == .signDate {
-                        if annotationModel?.fontName() == font.fontName {
-                            selectedIndex = index
-                        }
+                    if [.freeText, .signText, .signDate].contains(self.annotationType),
+                       let modelFontName = self.annotationModel?.fontName(),
+                       modelFontName == font.fontName {
+                        selectedIndex = index
                     }
                 }
             }
             
-            if annotationType == .freeText || annotationType == .signText || annotationType == .signDate {
-                if let data = annotationModel?.fontName() {
-                    let freetextFont = NSFont(name: data, size: 16) ?? NSFont.systemFont(ofSize: 16)
-                    if let family = freetextFont.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.family) as? String,
-                       let style = freetextFont.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.face) as? String {
+            if [.freeText, .signText, .signDate].contains(self.annotationType),
+               let data = self.annotationModel?.fontName() {
+                let freetextFont = NSFont(name: data, size: 16) ?? NSFont.systemFont(ofSize: 16)
+                if let family = freetextFont.fontDescriptor.object(forKey: .family) as? String,
+                   let style = freetextFont.fontDescriptor.object(forKey: .face) as? String {
+                    
+                    DispatchQueue.main.async { [weak self] in
+                        guard let self = self else { return }
                         
-                        DispatchQueue.main.async { [self] in
-                            fontPopUpButton.menu = menu
-                            fontPopUpButton.selectItem(at: selectedIndex)
-                            
-                            let selectedStyleIndex = setFontStyle(fontName: family, currentStyle: style)
-                            fontStylePopUpButton.selectItem(at: Int(selectedStyleIndex))
-                        }
+                        self.fontPopUpButton.menu = menu
+                        self.fontPopUpButton.selectItem(at: selectedIndex)
+                        
+                        let selectedStyleIndex = self.setFontStyle(fontName: family, currentStyle: style)
+                        self.fontStylePopUpButton.selectItem(at: Int(selectedStyleIndex))
                     }
                 }
             }

+ 9 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/View/KMFreeTextStylesViewController/KMFreeTextStylesViewController.m

@@ -513,6 +513,9 @@ typedef NS_ENUM(NSUInteger, KMFreeTextMenuActionType) {
     
     NSFontDescriptor *attributeFontDescriptor = [NSFontDescriptor fontDescriptorWithFontAttributes:@{NSFontFamilyAttribute:fontName,NSFontFaceAttribute:fontWeight}];
     NSFont *font = [NSFont fontWithDescriptor:attributeFontDescriptor size:fontSize];
+    if (font == nil) {
+        font = [NSFont fontWithName:fontName size:fontSize];
+    }
     NSDictionary *attrited = @{NSFontAttributeName:font, NSParagraphStyleAttributeName: paragraphStyle};
        
    CGRect rect = [fontStringValue boundingRectWithSize:CGSizeMake(135.0, CGRectMaxYEdge)
@@ -549,6 +552,9 @@ typedef NS_ENUM(NSUInteger, KMFreeTextMenuActionType) {
     
     NSFontDescriptor *attributeFontDescriptor = [NSFontDescriptor fontDescriptorWithFontAttributes:@{NSFontFamilyAttribute:fontName,NSFontFaceAttribute:fontWeight}];
     NSFont *font = [NSFont fontWithDescriptor:attributeFontDescriptor size:fontSize];
+    if (font == nil) {
+        font = [NSFont fontWithName:fontName size:fontSize];
+    }
     NSDictionary *attrited = @{NSFontAttributeName:font, NSForegroundColorAttributeName:fontColor};
     NSAttributedString *string = [[NSAttributedString alloc] initWithString:fontStringValue attributes:attrited];
     cellView.styleLabel.attributedStringValue = string;
@@ -645,6 +651,9 @@ typedef NS_ENUM(NSUInteger, KMFreeTextMenuActionType) {
     for (PDFAnnotation *tAnnotation in self.annotations) {
         NSFontDescriptor *attributeFontDescriptor = [NSFontDescriptor fontDescriptorWithFontAttributes:@{NSFontFamilyAttribute:fontName,NSFontFaceAttribute:fontWeight}];
         NSFont *font = [NSFont fontWithDescriptor:attributeFontDescriptor size:fontSize];
+        if (font == nil) {
+            font = [NSFont fontWithName:fontName size:fontSize];
+        }
         if (font) {
             tAnnotation.font = font;
         }

+ 8 - 6
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/WindowController/KMAnnotationFontWindowController.swift

@@ -199,7 +199,8 @@ class KMFontModel: NSObject {
     }
 
     func annotationFontReload() {
-        DispatchQueue.global(qos: .default).async { [self] in
+        DispatchQueue.global(qos: .default).async { [weak self] in
+            guard let self = self else { return }
             let fonts = NSFontManager.shared.availableFontFamilies
             let menu = NSMenu()
             var selectedIndex = 0
@@ -219,12 +220,13 @@ class KMFontModel: NSObject {
                     }
                 }
             }
-            DispatchQueue.main.async { [self] in
-                fontComboBox.menu = menu
-                fontComboBox.selectItem(at: selectedIndex)
+            DispatchQueue.main.async { [weak self] in
+                guard let self = self else { return }
+                self.fontComboBox.menu = menu
+                self.fontComboBox.selectItem(at: selectedIndex)
                 
-                let selectedStyleIndex = setFontStyle(fontName: annotationFontModel!.fontName, currentStyle: annotationFontModel!.fontWeight)
-                fontWeightPopUpButton.selectItem(at: Int(selectedStyleIndex))
+                let selectedStyleIndex = self.setFontStyle(fontName: self.annotationFontModel!.fontName, currentStyle: self.annotationFontModel!.fontWeight)
+                self.fontWeightPopUpButton.selectItem(at: Int(selectedStyleIndex))
             }
         }
     }

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureAnnotationViewController.m

@@ -116,7 +116,7 @@ KMSigntureViewItemDelegate>
 //    item.submenu = tSubMenu;
 //    [menu addItem:[NSMenuItem separatorItem]];
 //    [menu addItemWithTitle:NSLocalizedString(@"Delete stamp", nil) action:@selector(deleteCustomizeStamp) target:self];
-    [menu addItemWithTitle:NSLocalizedString(@"Delete All stamp", nil) action:@selector(deleteAllCustomizeStamp) target:self];
+    [menu addItemWithTitle:NSLocalizedString(@"Remove All", nil) action:@selector(deleteAllCustomizeStamp) target:self];
     self.collectionView.menu = menu;
 }
 

+ 3 - 3
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarItemView.swift

@@ -34,7 +34,7 @@ extension KMToolbarItemView {
             return self._itemIdentifier
         }
     }
-    var pdfView : CPDFListView = CPDFListView()
+    weak var pdfView: CPDFListView?
 
     lazy var clickButton: KMToolbarClickButton = {
         let view = KMToolbarClickButton()
@@ -831,11 +831,11 @@ extension KMToolbarItemView: KMCustomButtonPopMenuViewControllerDelegate, KMCust
     func itemEnable(at index: Int) -> Bool {
         if self.itemIdentifier == KMToolbarToolFormAlignIdentifier {
             if index <= 6 {
-                if self.pdfView.activeAnnotations.count >= 2 {
+                if let cnt = self.pdfView?.activeAnnotations.count, cnt >= 2 {
                     return true
                 }
             } else {
-                if self.pdfView.activeAnnotations.count >= 3 {
+                if let cnt = self.pdfView?.activeAnnotations.count, cnt >= 3 {
                     return true
                 }
             }

+ 20 - 125
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -2389,7 +2389,7 @@ extension KMMainViewController {
             return
         }
         let tabController = sender.object as? CTTabController
-        if tabController?.title == self.document?.documentURL.lastPathComponent {
+        if tabController?.title == self.document?.documentURL.deletingPathExtension().lastPathComponent {
             if let doc = self.myDocument, doc.isDocumentEdited {
                 Task {
                     let resp = await KMAlertTool.runModel(message: NSLocalizedString("File Updated", comment: ""), buttons: [NSLocalizedString("Save", comment: ""), NSLocalizedString("Cancel", comment: "")])
@@ -2410,8 +2410,8 @@ extension KMMainViewController {
         }
     }
     
-    func pdfSaveAlertView(_ sender: NSNotification) {
-        if AutoSaveManager.manager.isSaving{
+    func savePdfAlertView() {
+        if AutoSaveManager.manager.isSaving ||  AutoSaveManager.manager.isSaveNoti{
             return
         }
         AutoSaveManager.manager.isSaveNoti = true
@@ -2428,7 +2428,7 @@ extension KMMainViewController {
         }
     }
     
-    func pdfSaveFinishAlertView(_ sender: NSNotification) {
+    func savePdfFinishAlertView() {
         if !AutoSaveManager.manager.isSaveNoti{
             return
         }
@@ -2482,10 +2482,11 @@ extension KMMainViewController {
     func showInFinder(_ sender: Any) -> Void {
         if sender is NSNotification {
             let tabController = (sender as! NSNotification).object as? CTTabController
-            if tabController?.title == self.document?.documentURL.lastPathComponent {
-                let file: URL = (self.myDocument?.fileURL)!
-                if FileManager.default.fileExists(atPath: file.path) {
-                    NSWorkspace.shared.activateFileViewerSelecting([file])
+            if tabController?.title == self.document?.documentURL.deletingPathExtension().lastPathComponent {
+                if let file = self.myDocument?.fileURL {
+                    if FileManager.default.fileExists(atPath: file.path) {
+                        NSWorkspace.shared.activateFileViewerSelecting([file])
+                    }
                 }
             }
         } else {
@@ -2930,13 +2931,13 @@ extension KMMainViewController {
                 return
             }
         }
-        let extract = KMExtractImageWindowController(windowNibName: "KMExtractImageWindowController")
-        extract.docPath = fileURL?.path ?? ""
-        extract.password = document?.password ?? ""
-        extract.currentPage = self.listView.currentPageIndex
+        extract = KMExtractImageWindowController(windowNibName: "KMExtractImageWindowController")
+        extract?.docPath = fileURL?.path ?? ""
+        extract?.password = document?.password ?? ""
+        extract?.currentPage = self.listView.currentPageIndex
 //        extract.beginSheetModal(for: NSApp.mainWindow!, completionHandler: nil)
-        self.km_beginSheet(windowC: extract)
-        extract.selectCurrentPageBtn()
+        self.km_beginSheet(windowC: extract!)
+        extract?.selectCurrentPageBtn()
 //        self.showCreateStamp()
 //        self.showAddSignature()
     }
@@ -2999,6 +3000,7 @@ extension KMMainViewController {
     }
     
     internal func showPrintWindow(pageRange: KMPrintPageRange = KMPrintPageRange(type: .allPage, selectPages: [])) {
+        self.saveDocument()
         if (self.listView.document != nil && !self.listView.document.allowsPrinting) { // 有打印限制
             KMPasswordInputWindow.openWindow(window: self.view.window!, type: .owner,  url: self.listView.document.documentURL) { [weak self] result ,password in
                 if (result == .cancel) {
@@ -3009,29 +3011,11 @@ extension KMMainViewController {
                 // 隐藏提示
                 self?.hiddenSecureLimitTip()
                 // 去打印
-                if let data = self?.saveWatermarkFlag, !data {
-                    KMPrintWindowController.openDocument(inputDocument: self!.listView?.document, inputPageRange: pageRange)
-                    return
-                }
-                if let _url = KMTools.saveWatermarkDocumentToTemp(document: self!.listView.document, secureOptions: self!.secureOptions, removePWD: self!.removeSecureFlag) {
-                    _ = CPDFDocument(url: _url)
-                    KMPrintWindowController.showPrintWindowControll(inputData: _url, inputDocument: self?.listView.document, inputPageRange: pageRange)
-                } else {
-                    KMPrintWindowController.openDocument(inputDocument: self?.listView?.document, inputPageRange: pageRange)
-                }
+                KMPrintWindowController.openDocument(inputDocument: self?.listView?.document, inputPageRange: pageRange)
             }
             return
         }
-        if (!self.saveWatermarkFlag) {
-            KMPrintWindowController.openDocument(inputDocument: self.listView?.document, inputPageRange: pageRange)
-            return
-        }
-        if let _url = KMTools.saveWatermarkDocumentToTemp(document: self.listView.document, secureOptions: self.secureOptions, removePWD: self.removeSecureFlag) {
-            let _document = CPDFDocument(url: _url)
-            KMPrintWindowController.showPrintWindowControll(inputData: _url, inputDocument: self.listView.document, inputPageRange: pageRange)
-        } else {
-            KMPrintWindowController.openDocument(inputDocument: self.listView?.document, inputPageRange: pageRange)
-        }
+        KMPrintWindowController.openDocument(inputDocument: self.listView?.document, inputPageRange: pageRange)
     }
     
     // MARK: - 图片注释
@@ -3553,22 +3537,6 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
         #endif
         self.trackEvent_aiTranslate()
         self._aiTranslationPDFFileAction()
-//        Task { @MainActor in
-//            if await (KMLightMemberManager.manager.canPayFunction() == false) {
-//                let _ = KMSubscribeWaterMarkWindowController.show(window: self.view.window!, type: .aiTranslate) { isSub, _, isClose in
-//                    if (isClose) {
-//                        return
-//                    }
-//                    if (isSub) {
-//                        self._aiTranslationPDFFileAction()
-//                        return
-//                    }
-//                }
-//                return
-//            }
-//
-//            self._aiTranslationPDFFileAction()
-//        }
     }
     
     private func _aiTranslationPDFFileAction() {
@@ -3609,29 +3577,7 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
     }
     
     func toolbarViewController(_ viewController: KMToolbarViewController, shareDocument item: NSMenuItem) {
-        if (!self.saveWatermarkFlag) {
-            self.shareDocument(sender: viewController)
-            return
-        }
-        Task { @MainActor in
-            if await (KMLightMemberManager.manager.canPayFunction() == false) {
-                KMSubscribeWaterMarkWindowController.show(window: self.view.window!, isContinue: true) { isSubscribeSuccess, isWaterMarkExport, isClose in
-                    if (isClose) {
-                        return
-                    }
-                    if (isSubscribeSuccess) {
-                        self.shareDocument(sender: viewController)
-                        return
-                    }
-                    if (isWaterMarkExport) {
-                        self.shareDocument(sender: viewController, limit: true)
-                        return
-                    }
-                }
-                return
-            }
-            self.shareDocument(sender: viewController)
-        }
+        self.shareDocument(sender: viewController)
     }
     
     func toolbarViewController(_ viewController: KMToolbarViewController, shareFlatten item: NSMenuItem) {
@@ -3643,29 +3589,7 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
     }
     
     func toolbarViewController(_ viewController: KMToolbarViewController, shareOriginalPDF item: NSMenuItem) {
-        if (!self.saveWatermarkFlag) {
-            self.shareOriginalPDF(sender: viewController)
-            return
-        }
-        Task { @MainActor in
-            if await (KMLightMemberManager.manager.canPayFunction() == false) {
-                let _ = KMSubscribeWaterMarkWindowController.show(window: self.view.window!, isContinue: true) { isSubscribeSuccess, isWaterMarkExport, isClose in
-                    if (isClose) {
-                        return
-                    }
-                    if (isSubscribeSuccess) {
-                        self.shareOriginalPDF(sender: viewController)
-                        return
-                    }
-                    if (isWaterMarkExport) {
-                        self.shareOriginalPDF(sender: viewController, limit: true)
-                        return
-                    }
-                }
-                return
-            }
-            self.shareOriginalPDF(sender: viewController)
-        }
+        self.shareOriginalPDF(sender: viewController)
     }
     
     func toolbarViewController(_ viewController: KMToolbarViewController, scanOCRModel selectedTag: Int) {
@@ -3753,27 +3677,6 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                     return
                 }
                 
-                if await (KMLightMemberManager.manager.canPayFunction() == false) {
-//                    self.view.window?.contentView?.superview?.beginLoading()
-                    let document = self.listView.document
-                    let secureOptions = self.secureOptions
-                    let removeSecureFlag = self.removeSecureFlag
-                    
-//                    DispatchQueue.global().async { [unowned self] in
-                        guard let _url = KMTools.saveWatermarkDocumentToTemp(document: document!, secureOptions: secureOptions, removePWD: removeSecureFlag) else {
-//                            DispatchQueue.main.async {
-//                                self.view.window?.contentView?.superview?.endLoading()
-//                            }
-                            return
-                        }
-//                        DispatchQueue.main.async {
-//                            self.view.window?.contentView?.superview?.endLoading()
-                            self.showCompressWindow(url: _url)
-//                        }
-//                    }
-                    return
-                }
-                
                 if (self.needSaveDocument()) {
                     self.saveDocumentWithProgressAlert { [unowned self] params in
                         self.showCompressWindow()
@@ -3821,14 +3724,6 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                     return
                 }
                 
-                if await (KMLightMemberManager.manager.canPayFunction() == false) {
-                    guard let _url =  KMTools.saveWatermarkDocumentToTemp(document: self.listView.document, secureOptions: self.secureOptions, removePWD: self.removeSecureFlag) else {
-                        return
-                    }
-                    self.showMergeWindow(url: _url, self.model.password)
-                    return
-                }
-                
                 if (self.needSaveDocument()) {
                     self.saveDocumentWithProgressAlert { [unowned self] params in
                         self.showMergeWindow(self.listView.document.password)

+ 4 - 1
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift

@@ -1150,14 +1150,17 @@ extension KMMainViewController: KMSystemToolMenuProtocol {
     }
     
     func togglePoster(_ sender: Any?) {
+        self.saveDocument()
         KMPrintWindowController.showNewPrintWindowControll(inputDocument: self.listView.document, inputPageRange: KMPrintPageRange(), printType: .poster)
     }
     
     func toggleMultiple(_ sender: Any?) {
+        self.saveDocument()
         KMPrintWindowController.showNewPrintWindowControll(inputDocument: self.listView.document, inputPageRange: KMPrintPageRange(), printType: .multipage)
     }
     
     func toggleBooklet(_ sender: Any?) {
+        self.saveDocument()
         KMPrintWindowController.showNewPrintWindowControll(inputDocument: self.listView.document, inputPageRange: KMPrintPageRange(), printType: .pamphlet)
     }
     
@@ -1336,7 +1339,7 @@ extension KMMainViewController {
 extension KMMainViewController {
     override func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
         if (menuItem.action == #selector(menuItemAction_currentWindowName)) {
-            menuItem.title = (self.myDocument?.fileURL!.lastPathComponent)!
+            menuItem.title = (self.myDocument?.fileURL?.lastPathComponent) ?? ""
             return true
         }
         

+ 86 - 40
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift

@@ -137,54 +137,100 @@ extension KMMainViewController {
         }
     }
     
-    func convertNotesUsingPDFDocument(_ pdfDocument: CPDFDocument) {
-        beginProgressSheet(withMessage: NSLocalizedString("Converting notes", comment: "Message for progress sheet").appending("..."), maxValue: 0)
-        
-        let count = pdfDocument.pageCount
-        let pdfView = listView
+    func showConvertNotesProgress() {
+        guard let pdfDocument = self.document else {
+            return
+        }
+        guard let _ = self.listView?.document else {
+            return
+        }
+        guard let _ = self.view.window else {
+            return
+        }
         
-        for i in 0..<count {
-            let page = pdfDocument.page(at: i)
-            
-            var addAnnotations = [CPDFAnnotation]()
-            var removeAnnotations = [CPDFAnnotation]()
+        self.model.needConvertNotes = false
+        Task { @MainActor in
+            self.convertNotesUsingPDFDocument(pdfDocument)
+        }
+    }
+    
+    func convertNotesUsingPDFDocument(_ pdfDocument: CPDFDocument) {
+        guard let doc = self.listView?.document else {
+            return
+        }
+        DispatchQueue.main.async {
+            self.beginProgressSheet(withMessage: NSLocalizedString("Converting notes", comment: "Message for progress sheet").appending("..."), maxValue: 0)
             
-            for annotation in page?.annotations ?? [] {
-                var newAnnotation: CPDFAnnotation?
-                if let inkAnnotation = annotation as? CPDFInkAnnotation, inkAnnotation.contents.hasPrefix("<?xml version=\"1.0\" encoding=\"utf-8\"?>") {
-                    let table = KMTableAnnotation(KMNoteBounds: inkAnnotation.bounds, document: pdfView!.document)
-                    table.border = inkAnnotation.border
-                    table.color = inkAnnotation.color
-                    table.createForm(withList: inkAnnotation.contents, andPaths: inkAnnotation.bezierPaths())
-                    table.updateAppearanceInk(withIsAdd: false)
-                    table.contents = annotation.contents
-                    newAnnotation = table
-                }
-                if let newAnnotation = newAnnotation {
-                    addAnnotations.append(newAnnotation)
-                    removeAnnotations.append(annotation)
+            let count = pdfDocument.pageCount
+            DispatchQueue.global().async {
+//                var addAnnotations = [CPDFAnnotation]()
+//                var removeAnnotations = [CPDFAnnotation]()
+                self.model.addAnnotations.removeAll()
+                self.model.removeAnnotations.removeAll()
+                for i in 0..<count {
+                    let page = pdfDocument.page(at: i)
+                    
+                    //                var addAnnotations = [CPDFAnnotation]()
+                    //                var removeAnnotations = [CPDFAnnotation]()
+                    for annotation in page?.annotations ?? [] {
+                        var newAnnotation: CPDFAnnotation?
+                        if let inkAnnotation = annotation as? CPDFInkAnnotation, inkAnnotation.contents.hasPrefix("<?xml version=\"1.0\" encoding=\"utf-8\"?>") {
+                            let table = KMTableAnnotation(KMNoteBounds: inkAnnotation.bounds, document: doc)
+                            table.border = inkAnnotation.border
+                            table.color = inkAnnotation.color
+                            table.createForm(withList: inkAnnotation.contents, andPaths: inkAnnotation.bezierPaths())
+                            table.updateAppearanceInk(withIsAdd: false)
+                            table.contents = annotation.contents
+                            newAnnotation = table
+                        }
+                        if let newAnnotation = newAnnotation {
+                            self.model.addAnnotations.append(newAnnotation)
+                            self.model.removeAnnotations.append(annotation)
+                        }
+                    }
+                    
+                    //                for i in 0..<addAnnotations.count {
+                    //                    let newAnnotation = addAnnotations[i]
+                    //                    let annotation = removeAnnotations[i]
+                    //
+                    //                    // this is only to make sure markup annotations generate the lineRects, for thread safety
+                    //                    pdfView?.addAnnotation(with: newAnnotation, to: page)
+                    //                    pdfView?.remove(annotation)
+                    //                    if newAnnotation.contents != nil {
+                    //                        if newAnnotation.contents.count == 0 {
+                    //                            newAnnotation.autoUpdateString()
+                    //                        }
+                    //                    }
+                    //                }
                 }
-            }
-            
-            for i in 0..<addAnnotations.count {
-                let newAnnotation = addAnnotations[i]
-                let annotation = removeAnnotations[i]
                 
-                // this is only to make sure markup annotations generate the lineRects, for thread safety
-                pdfView!.addAnnotation(with: newAnnotation, to: page)
-                pdfView!.remove(annotation)
-                if newAnnotation.contents != nil {
-                    if newAnnotation.contents.count == 0 {
-                        newAnnotation.autoUpdateString()
+                DispatchQueue.main.async {
+                    for i in 0..<self.model.addAnnotations.count {
+                        let newAnnotation = self.model.addAnnotations[i]
+                        let annotation = self.model.removeAnnotations[i]
+                        
+                        let page = annotation.page
+                        // this is only to make sure markup annotations generate the lineRects, for thread safety
+                        self.listView?.addAnnotation(with: newAnnotation, to: page)
+                        self.listView?.remove(annotation)
+                        if newAnnotation.contents != nil {
+                            if newAnnotation.contents.count == 0 {
+                                newAnnotation.autoUpdateString()
+                            }
+                        }
                     }
+                    
+                    self.dismissProgressSheet()
+                    
+                    self.listView?.undoManager?.removeAllActions()
+                    self.undoManager?.removeAllActions()
+                    
+                    // 清空数据
+                    self.model.addAnnotations.removeAll()
+                    self.model.removeAnnotations.removeAll()
                 }
             }
         }
-        
-        dismissProgressSheet()
-        
-        pdfView?.undoManager?.removeAllActions()
-        undoManager?.removeAllActions()
     }
     
     // MARK: - KMInterfaceThemeChangedProtocol

+ 39 - 13
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift

@@ -133,6 +133,8 @@ import Cocoa
     let CPDFOfficeLeftSidePaneWidthKey = "CPDFOfficeLeftSidePaneWidthKey"
     let CPDFOfficeRightSidePaneWidthKey = "CPDFOfficeRightSidePaneWidthKey"
     
+    var extract: KMExtractImageWindowController?
+    
     var functionWidth: Double {
         get {
             if self.isReadMode {
@@ -275,6 +277,9 @@ import Cocoa
         }
         
         if (self.document?.isLocked == false) {
+            if self.model.needConvertNotes && self.tabViewIsDragging() == false {
+                self.showConvertNotesProgress()
+            }
             return
         }
         if (self.view.window == nil) {
@@ -283,16 +288,20 @@ import Cocoa
         if (self.model.password != nil) {
             if self.listView.document.unlock(withPassword: self.model.password) {
                 self.model.isSaveKeyChain = false
+                if self.model.needConvertNotes && self.tabViewIsDragging() == false {
+                    self.showConvertNotesProgress()
+                }
                 return
             }
         }
         
         DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.3) {
-            if self.passwordWindow == nil && self.view.window != nil {
+            if self.passwordWindow == nil && self.view.window != nil && self.tabViewIsDragging() == false {
                 self.passwordWindow = KMPasswordInputWindow.openWindow(window: self.view.window!, url: self.document!.documentURL) { [unowned self] result , password in
                     self.passwordWindow = nil
                     if (result == .cancel) {
-                        self.browserWindowController?.browser?.closeTab()
+//                        self.browserWindowController?.browser?.closeTab()
+                        (self.myDocument as? KMMainDocument)?.browser.closeTab()
                         return
                     }
                     self.model.isSaveKeyChain = true
@@ -302,6 +311,10 @@ import Cocoa
             } else {
                 self.passwordWindow = nil
             }
+            
+            if self.model.needConvertNotes && self.tabViewIsDragging() == false {
+                self.showConvertNotesProgress()
+            }
         }
     }
     
@@ -373,10 +386,12 @@ import Cocoa
         pageNumberDisplayView.delegate = self
         
         tipCurrentPageBox.moveCallback = { [unowned self] mouseEntered, mouseBox in
-            if mouseEntered {
-                self.pageNumberDisplayView.hover = true
-            } else {
-                self.pageNumberDisplayView.hover = false
+            if !isReadMode {
+                if mouseEntered {
+                    self.pageNumberDisplayView.hover = true
+                } else {
+                    self.pageNumberDisplayView.hover = false
+                }
             }
         }
 
@@ -400,8 +415,6 @@ import Cocoa
         NotificationCenter.default.addObserver(self, selector: #selector(didShowFullScreenNotification), name: NSWindow.didShowFullScreenNotification, object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(didAddContentViewNotification), name: NSWindow.didAddContentViewNotification, object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(addAutoSaveEvent), name: AutoSaveManager.kTimeValueChangedNotificationName, object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(pdfSaveAlertView(_:)), name: Notification.Name("kCPDFDocumentDidBeginWriteNotification"), object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(pdfSaveFinishAlertView(_:)), name: Notification.Name("kCPDFDocumentDidEndWriteNotification"), object: nil)
         
         Task {
             self.addAutoSaveEvent()
@@ -754,7 +767,7 @@ import Cocoa
         windowVC.showWindow(nil)
         if (aiConfigType != .none) {
             windowVC.eventLabel = "AITools_Start"
-            if self.listView.currentSelection?.string().isEmpty == false {
+            if self.listView.currentSelection?.string()?.isEmpty == false {
                 windowVC.setCurrentPDFSelection(self.listView.currentSelection.string())
             }
             windowVC.chooseAIFunctionWithType(aiConfigType)
@@ -1027,6 +1040,9 @@ import Cocoa
         
         if let data = editController?.isEdited, data {
             self.leftSideViewController.reloadThumbnailDataIfNeed()
+            self.leftSideViewController.note_reloadDataIfNeed()
+            self.leftSideViewController.refreshUIOfOutlineIfNeed()
+            self.leftSideViewController.refreshUIOfSeachListIfNeed()
         }
     }
     
@@ -1073,7 +1089,7 @@ import Cocoa
     
     func exitDigitalSign() {
         self.digitalSignController?.view.removeFromSuperview()
-        self.digitalSignController = nil
+//        self.digitalSignController = nil
         
         self.toolbarController.findItem(KMDocumentDigitalSignToolbarItemIdentifier)?.isSelected = false
     }
@@ -1120,6 +1136,8 @@ import Cocoa
             digitalSignView.frame = splitViewSuperview.bounds
             digitalSignView.autoresizingMask = [.width, .height]
             splitViewSuperview.addSubview(digitalSignView)
+            
+            digitalSignController?.setCurrentPageIndex(Int(currentPageIndex))
         }
     }
     
@@ -1879,6 +1897,8 @@ import Cocoa
         }
         self.removeAutoSaveInfo()
         KMAdsManager.defaultManager.dismissSheetModal(for: self.readContentView)
+//        self.myDocument = nil
+        
     }
     
     public func clearSecureOptions() {
@@ -1935,8 +1955,8 @@ import Cocoa
             self.showSecureLimitTip()
         }
         
-        if self.document != nil {
-            self.convertNotesUsingPDFDocument(self.document!)
+        if self.model.needConvertNotes {
+            self.showConvertNotesProgress()
         }
         if (self._documentFirstLoad) {
             self.checkShouldAutoOpenLeftVC()
@@ -1958,6 +1978,11 @@ import Cocoa
         }
     }
     
+    func tabViewIsDragging() -> Bool {
+        let level = self.view.window?.level ?? .normal
+        return level == .floating
+    }
+    
     // MARK: - Noti Actions
     
     internal func documentDidUnlockNotification(_ sender: Notification) {
@@ -1970,7 +1995,8 @@ import Cocoa
                 self.hiddenSecureLimitTip()
             }
             
-            if ((self.myDocument as! KMMainDocument).isUnlockFromKeychain || self.model.isSaveKeyChain == false) {
+            let isUnlockFromKeychain = (self.myDocument as? KMMainDocument)?.isUnlockFromKeychain ?? false
+            if (isUnlockFromKeychain || self.model.isSaveKeyChain == false) {
                 return
             }
             

+ 5 - 0
PDF Office/PDF Master/Class/PDFWindowController/ViewController/Model/KMMainModel.swift

@@ -54,4 +54,9 @@ extension KMMainModel.Key {
     var markedPageIndex = NSNotFound
     var beforeMarkedPagePoint = NSPoint.zero
     var markedPagePoint = NSPoint.zero
+    
+    var needConvertNotes = true
+    
+    var addAnnotations: [CPDFAnnotation] = []
+    var removeAnnotations: [CPDFAnnotation] = []
 }

+ 1 - 0
PDF Office/PDF Master/Class/PDFWindowController/ViewController/Views/KMPageNumberDisplayView/KMPageNumberDisplayView.swift

@@ -232,6 +232,7 @@ extension KMPageNumberDisplayView {
     func dismiss() {
         self.timer?.invalidate()
         self.timer = nil
+        self.alphaValue = 0
     }
     
     func updateViewDispaly() {

+ 2 - 0
PDF Office/PDF Master/Class/Purchase/DMG/Verification/KMVerificationWindowController.h

@@ -38,4 +38,6 @@ typedef NS_ENUM(NSInteger, KMVerificationType) {
 
 + (BOOL)allowRepeatTrialExpireShow;//是否允许弹出二次试用过期弹窗
 
++ (void)verificationFeedback;
+
 @end

+ 107 - 0
PDF Office/PDF Master/Class/Purchase/DMG/Verification/KMVerificationWindowController.m

@@ -947,4 +947,111 @@ fail:
     });
 }
 
++ (void)verificationFeedback {
+    unsigned major, minor, bugFix;
+    [self getSystemVersionMajor:&major minor:&minor bugFix:&bugFix];
+    NSString *versionString = [NSString stringWithFormat:@"%@ - %u.%u.%u", [GBDeviceInfo deviceInfo].rawSystemInfoString, major, minor, bugFix];
+    
+    NSString *tAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
+    if ([tAppVersion length] < 1)
+    {
+        tAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
+    }
+    
+    NSString* subjects = [[self getAppNameForSupportEmail] stringByAppendingFormat:NSLocalizedString(@" - %@;Verification Feedback;%@", nil) ,tAppVersion,versionString];
+    [KMMailHelper newEmailWithContacts:@"support@pdfreaderpro.com" andSubjects:subjects];
+}
+
++ (void)getSystemVersionMajor:(unsigned *)major
+                        minor:(unsigned *)minor
+                       bugFix:(unsigned *)bugFix;
+{
+    OSErr err;
+    SInt32 systemVersion, versionMajor, versionMinor, versionBugFix;
+    
+    if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) {
+        NSOperatingSystemVersion osSystemVersion = [[NSProcessInfo processInfo] operatingSystemVersion];
+        
+        *major = (unsigned)osSystemVersion.majorVersion;
+        *minor = (unsigned)osSystemVersion.minorVersion;
+        *bugFix = (unsigned)osSystemVersion.patchVersion;
+        
+        return;
+    } else {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+        if ((err = Gestalt(gestaltSystemVersion, &systemVersion)) != noErr) goto fail;
+        if (systemVersion < 0x1040)
+        {
+            if (major) *major = ((systemVersion & 0xF000) >> 12) * 10 +
+                ((systemVersion & 0x0F00) >> 8);
+            if (minor) *minor = (systemVersion & 0x00F0) >> 4;
+            if (bugFix) *bugFix = (systemVersion & 0x000F);
+        }
+        else
+        {
+            if ((err = Gestalt(gestaltSystemVersionMajor, &versionMajor)) != noErr) goto fail;
+            if ((err = Gestalt(gestaltSystemVersionMinor, &versionMinor)) != noErr) goto fail;
+            if ((err = Gestalt(gestaltSystemVersionBugFix, &versionBugFix)) != noErr) goto fail;
+            if (major) *major = versionMajor;
+            if (minor) *minor = versionMinor;
+            if (bugFix) *bugFix = versionBugFix;
+        }
+        
+        return;
+#pragma clang diagnostic pop
+    }
+    
+fail:
+    NSLog(@"Unable to obtain system version: %ld", (long)err);
+    if (major) *major = 10;
+    if (minor) *minor = 0;
+    if (bugFix) *bugFix = 0;
+}
+
++ (NSString *)getAppNameForSupportEmail
+{
+    NSString *tAppName = @"PDF Reader Pro";
+    
+#if VERSION_FREE
+    
+#if VERSION_DMG
+    // 桌机版
+    VerificationManager *tManager = [VerificationManager manager];
+    switch ([tManager status]) {
+        case ActivityStatusTrial:
+            tAppName = @"PDF Reader Pro Trial";
+            break;
+            
+        case ActivityStatusVerification:
+            tAppName = @"PDF Reader Pro Verification";
+            break;
+            
+        case ActivityStatusTrialExpire:
+            tAppName = @"PDF Reader Pro TrialExpire";
+            break;
+            
+        case ActivityStatusVerifExpire:
+            tAppName = @"PDF Reader Pro VerifExpire";
+            break;
+            
+        default:
+            break;
+    }
+    
+#else
+    
+    // AppStore 免费版本
+    tAppName = @"PDF Reader Pro Lite";
+#endif
+    
+#else
+    
+    // AppStore 付费版
+    tAppName = @"PDF Reader Pro Edition";
+#endif
+    
+    return tAppName;
+}
+
 @end