Browse Source

ComPDFKit(RN) - iOS端的文档保存调整

yangliuhua 2 months ago
parent
commit
099039f642
2 changed files with 7 additions and 2 deletions
  1. 1 1
      ios/ComPDFKitRN.swift
  2. 6 1
      ios/RCTCPDFView.swift

+ 1 - 1
ios/ComPDFKitRN.swift

@@ -131,7 +131,7 @@ class ComPDFKit: NSObject, CPDFViewBaseControllerDelete{
     func openDocument(document : URL, password: String, configurationJson : String) -> Void {
     func openDocument(document : URL, password: String, configurationJson : String) -> Void {
         DispatchQueue.main.async {
         DispatchQueue.main.async {
             let fileManager = FileManager.default
             let fileManager = FileManager.default
-            let samplesFilePath = NSHomeDirectory().appending("/Documents/BasicViewer")
+            let samplesFilePath = NSHomeDirectory().appending("/Documents/Files")
             let fileName = document.lastPathComponent
             let fileName = document.lastPathComponent
             let docsFilePath = samplesFilePath + "/" + fileName
             let docsFilePath = samplesFilePath + "/" + fileName
             
             

+ 6 - 1
ios/RCTCPDFView.swift

@@ -38,7 +38,7 @@ class RCTCPDFView: UIView {
     
     
     private func createCPDFView() {
     private func createCPDFView() {
         let fileManager = FileManager.default
         let fileManager = FileManager.default
-        let samplesFilePath = NSHomeDirectory().appending("/Documents/ReaderViewer")
+        let samplesFilePath = NSHomeDirectory().appending("/Documents/Files")
         let fileName = document.lastPathComponent
         let fileName = document.lastPathComponent
         let docsFilePath = samplesFilePath + "/" + fileName
         let docsFilePath = samplesFilePath + "/" + fileName
         
         
@@ -73,12 +73,17 @@ class RCTCPDFView: UIView {
                 let document = self.pdfViewController?.pdfListView?.document
                 let document = self.pdfViewController?.pdfListView?.document
                 let success = document?.write(to: document?.documentURL ?? URL(fileURLWithPath: ""), isSaveFontSubset: true) ?? false
                 let success = document?.write(to: document?.documentURL ?? URL(fileURLWithPath: ""), isSaveFontSubset: true) ?? false
                 completionHandler(success)
                 completionHandler(success)
+            } else {
+                completionHandler(true)
             }
             }
+            
         } else {
         } else {
             if self.pdfViewController?.pdfListView?.document.isModified() == true {
             if self.pdfViewController?.pdfListView?.document.isModified() == true {
                 let document = self.pdfViewController?.pdfListView?.document
                 let document = self.pdfViewController?.pdfListView?.document
                 let success = document?.write(to: document?.documentURL ?? URL(fileURLWithPath: ""), isSaveFontSubset: true) ?? false
                 let success = document?.write(to: document?.documentURL ?? URL(fileURLWithPath: ""), isSaveFontSubset: true) ?? false
                 completionHandler(success)
                 completionHandler(success)
+            } else {
+                completionHandler(true)
             }
             }
         }
         }
     }
     }