Explorar el Código

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

liujiajie hace 6 meses
padre
commit
297aaeca7d

+ 5 - 2
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] = []

+ 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") {

+ 2 - 46
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -3555,29 +3555,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) {
@@ -3589,29 +3567,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) {