Parcourir la source

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

tangchao il y a 10 mois
Parent
commit
30c9744989

+ 2 - 0
PDF Office/PDF Master/Class/PDFTools/Watermark/Controller/KMBatchOperateAddWatermarkViewController.swift

@@ -129,6 +129,8 @@ class KMBatchOperateAddWatermarkViewController: KMBatchOperateBaseViewController
         self._configuiUI()
         self._loadData()
         
+        self.interfaceStatus = .PrepareProcess
+        
         NotificationCenter.default.addObserver(self, selector: #selector(_watermarksNotification), name: NSNotification.Name("KMBatchOperateWatermarksNotification"), object: nil)
     }
      

+ 4 - 4
PDF Office/PDF Master/Class/PDFTools/Watermark/Model/KMBatchAddBackgroundOperation.swift

@@ -112,13 +112,13 @@ class KMBatchAddBackgroundOperation: KMBatchOperation{
         tBackground.xOffset = background.horizontalSpace
         tBackground.yOffset = background.verticalSpace
 
-        if let color = background.color {
-            tBackground.color = color
-            tBackground.type = .color
-        } else if background.imagePath.count != 0 {
+        if background.imagePath.count != 0 {
             let image = NSImage(contentsOfFile: background.imagePath)!
             tBackground.setImage(image)
             tBackground.type = .image
+        } else if let color = background.color {
+            tBackground.color = color
+            tBackground.type = .color
         }
 
         if background.pagesString.count != 0 {

+ 4 - 4
PDF Office/PDF Master/Class/PDFTools/Watermark/New/View/KMWatermarkView.swift

@@ -1069,14 +1069,14 @@ extension KMWatermarkView {
             }
             var property: CPDFWatermark!
             var scale: CGFloat = model.scale
-            if (!model.text.isEmpty) {
+            if model.image != nil {
+                property = CPDFWatermark(document: waterDocument, type: .image)
+                property.image = model.image
+            } else {
                 property = CPDFWatermark(document: waterDocument, type: .text)
                 property.text = model.text
                 property.textColor = model.getTextColor()
                 scale = model.getTextFontSize() / 24.0
-            } else {
-                property = CPDFWatermark(document: waterDocument, type: .image)
-                property.image = model.image
             }
             
             property.scale = scale

+ 7 - 6
PDF Office/PDF Master/Class/PDFTools/Watermark/Tools/KMWatermarkManager.swift

@@ -381,12 +381,8 @@ class KMWatermarkManager: NSObject {
         
         let isText: Bool = (dict.object(forKey: KMWatermarkKey.text.rawValue) != nil)
         let isFile: Bool = (dict.object(forKey: KMWatermarkKey.imagePath.rawValue) != nil)
-        if (isText) {
-            model.text = (dict.object(forKey: KMWatermarkKey.text.rawValue) as! String)
-            let fontSize: CGFloat = dict.object(forKey: KMWatermarkKey.textFontSize.rawValue) as! CGFloat
-//            let fontName: String = dict.object(forKey: KMWatermarkKey.textFontName.rawValue) as! String
-            model.textFont = .font(name: "Helvetica", size: fontSize)
-        } else if (isFile) {
+        
+        if (isFile) {
             let path = watermarkFolderPath?.stringByAppendingPathComponent(dict.object(forKey: KMWatermarkKey.imagePath.rawValue) as! String)
             if (FileManager.default.fileExists(atPath: path!)) {
                 model.image = NSImage(contentsOfFile: path!)
@@ -394,6 +390,11 @@ class KMWatermarkManager: NSObject {
             } else {
                 model.image = nil
             }
+        } else if (isText) {
+            model.text = (dict.object(forKey: KMWatermarkKey.text.rawValue) as! String)
+            let fontSize: CGFloat = dict.object(forKey: KMWatermarkKey.textFontSize.rawValue) as! CGFloat
+//            let fontName: String = dict.object(forKey: KMWatermarkKey.textFontName.rawValue) as! String
+            model.textFont = .font(name: "Helvetica", size: fontSize)
         }
         
         model.scale = (dict.object(forKey: KMWatermarkKey.scale.rawValue) as? CGFloat) ?? 1