Browse Source

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

tangchao 1 year ago
parent
commit
4751379e08

+ 8 - 8
PDF Office/PDF Master.xcodeproj/project.pbxproj

@@ -6983,6 +6983,13 @@
 			path = View;
 			sourceTree = "<group>";
 		};
+		AD199DE42B2075A500D56FEE /* Multipage */ = {
+			isa = PBXGroup;
+			children = (
+			);
+			path = Multipage;
+			sourceTree = "<group>";
+		};
 		AD1CA3F42A05FC6A0070541F /* KMScreenViewController */ = {
 			isa = PBXGroup;
 			children = (
@@ -7252,13 +7259,6 @@
 			path = Poster;
 			sourceTree = "<group>";
 		};
-		AD58F40B2B1DA92700299EE0 /* Multipage */ = {
-			isa = PBXGroup;
-			children = (
-			);
-			path = Multipage;
-			sourceTree = "<group>";
-		};
 		AD58F40C2B1DA92F00299EE0 /* Pamphlet */ = {
 			isa = PBXGroup;
 			children = (
@@ -7277,8 +7277,8 @@
 		AD58F4222B1DC29A00299EE0 /* View */ = {
 			isa = PBXGroup;
 			children = (
+				AD199DE42B2075A500D56FEE /* Multipage */,
 				AD58F40C2B1DA92F00299EE0 /* Pamphlet */,
-				AD58F40B2B1DA92700299EE0 /* Multipage */,
 				AD58F40A2B1DA90900299EE0 /* Poster */,
 				AD58F4092B1DA90100299EE0 /* Custom */,
 			);

+ 10 - 10
PDF Office/PDF Master/Class/Batch/Tools/KMImageToPDFMethod.swift

@@ -129,11 +129,11 @@ class KMImageToPDFMethod: NSObject, KMGOCRManagerDelegate {
         if (pdf?.pageCount ?? 0) < 1 {
             
         } else {
-            let attributes = NSMutableDictionary(dictionary: pdf!.documentAttributes()!, copyItems: true)
-            if ((pdf?.isEncrypted) != nil) {
-                attributes.setValue(password, forKey: (kCGPDFContextUserPassword as NSString) as String)
-                attributes.setValue(password, forKey: (kCGPDFContextOwnerPassword as NSString) as String)
-                isSucceed = ((pdf?.write(toFile: newPath, withOptions: (attributes as? [CPDFDocumentWriteOption : Any]))) != nil)
+            var options: [CPDFDocumentWriteOption : Any] = [:]
+            if pdf!.isEncrypted {
+                options.updateValue(password, forKey: .userPasswordOption)
+                options.updateValue(password, forKey: .userPasswordOption)
+                isSucceed = ((pdf?.write(toFile: newPath, withOptions: options)) != nil)
             } else {
                 isSucceed = pdf?.write(toFile: newPath) ?? false
             }
@@ -154,11 +154,11 @@ class KMImageToPDFMethod: NSObject, KMGOCRManagerDelegate {
             return
         }
         let filePath: String = photoArray?[convertIndex] as! String
-        var savePath = path
+        let savePath = path
         var isDir: ObjCBool = false
         if FileManager.default.fileExists(atPath: filePath , isDirectory: &isDir) && !isDir.boolValue {
             let model = KMImageModel(filepath: filePath )
-            let tString = model.photoName.deletingPathExtension
+            let tString = model.photoName.deletingPathExtension.lastPathComponent//model.photoName.deletingPathExtension
             
             var newpath = path.stringByAppendingPathComponent(tString).stringByAppendingPathExtension("pdf")
             newpath = getUniqueFilePath(newpath)
@@ -169,10 +169,10 @@ class KMImageToPDFMethod: NSObject, KMGOCRManagerDelegate {
                 _ = pdf?.km_insertPage(imag.size, withImage: filePath , at: pdf?.pageCount ?? 0)
             }
             
-            DispatchQueue.global().async {
+//            DispatchQueue.global().async {
                 var isSucceed = false
                 
-                isSucceed = ((pdf?.write(toFile: path)) != nil)
+                isSucceed = ((pdf?.write(toFile: newpath)) != nil)
                 var pre: Float = 0
                 if self.photoArray?.count ?? 0 > 0{
                     pre = Float(self.convertIndex + 1) / Float(self.photoArray?.count ?? 1)
@@ -196,7 +196,7 @@ class KMImageToPDFMethod: NSObject, KMGOCRManagerDelegate {
                         complete(path, self.errorArray as! Array<Any>, self.errorOCRArray as! Array<Any>)
                     }
                 }
-            }
+//            }
             
         } else {
             if convertIndex < (photoArray?.count ?? 0) - 1 {

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Print/Model/KMPrintPageModel.swift

@@ -105,7 +105,7 @@ struct KMPrintPageOperation {
             case page6 = "6"
             case page9 = "9"
             case page16 = "16"
-            case custom = "custom"
+            case custom = "Custom"
             
             static func allValues() -> [String] {
                 var array: [String] = []

+ 3 - 1
PDF Office/PDF Master/Class/PDFTools/Print/Model/KMPrintPaperModel.swift

@@ -37,11 +37,13 @@ enum KMPrintPaperDirectionType: String, CaseIterable {
 struct KMPrintPaperInfo {
     var type: KMPaperType = .A4
     var inset: NSEdgeInsets = NSEdgeInsetsMake(20, 20, 20, 20)
+    var customSize: CGSize = CGSize(width: 210, height: 297)
     var size: CGSize {
         return KMPaperType.paperSize(type: type, px: true)
     }
     
     enum KMPaperType: String, CaseIterable {
+        case Actual = "Actual Size"
         case A3 = "A3"
         case A4 = "A4"
         case A5 = "A5"
@@ -56,7 +58,7 @@ struct KMPrintPaperInfo {
         case Tabloid_Oversize = "Tabloid Oversize"
         case US_Legal = "US Legal"
         case US_Letter = "US Letter"
-        case custom = "custom"
+        case custom = "Custom"
         
         static func allValues() -> [String] {
             var array: [String] = []

+ 308 - 14
PDF Office/PDF Master/Class/PDFTools/Print/View/PrintSettingView/View/Poster/KMPrintPosterView.swift

@@ -83,10 +83,10 @@ class KMPrintPosterView: KMBaseXibView {
         
         unitComboBox.selectItem(at: 1)
 
-        let paperArray = KMPageSizeTool.paperSize()
+        var paperArray = KMPrintPaperInfo.KMPaperType.allValues()
         var tPaperArray = paperArray
-        tPaperArray.append(NSLocalizedString("Custom", comment: ""))
-
+        tPaperArray.removeFirst()
+        
         splitSizeComboBox.addItems(withObjectValues: tPaperArray)
         splitSizeComboBox.selectItem(at: 1)
         splitSizeComboBox.isEditable = false
@@ -94,16 +94,13 @@ class KMPrintPosterView: KMBaseXibView {
         pageHeightTextField.isEnabled = false
 
         var tFileArray = paperArray
-        tFileArray.insert(NSLocalizedString("Actual Size", comment: ""), at: 0)
-        tFileArray.append(NSLocalizedString("Custom", comment: ""))
-
         filePageSizeBox.addItems(withObjectValues: tFileArray)
         filePageSizeBox.selectItem(at: 0)
         filePageSizeBox.isEditable = false
         paperWidthTextField.isEnabled = false
         paperHeightTextField.isEnabled = false
 
-        selectPerComboBox.addItems(withObjectValues: ["2", "4", "6", "9", "16", NSLocalizedString("Custom", comment: "")])
+        selectPerComboBox.addItems(withObjectValues: KMPrintPageOperation.PageOfPaper.PageType.allValues())
         selectPerComboBox.selectItem(at: 5)
         selectPerComboBox.isEditable = false
         
@@ -128,6 +125,7 @@ class KMPrintPosterView: KMBaseXibView {
         overlapLabel.stringValue = NSLocalizedString("Overlap:", comment: "")
         commentsFormsLabel.stringValue = NSLocalizedString("Comments & Forms:", comment: "")
 
+        pageRangeComboBox.removeAllItems()
         pageRangeComboBox.addItems(withObjectValues: [
             NSLocalizedString("All Pages", comment: ""),
             NSLocalizedString("Odd Pages Only", comment: ""),
@@ -136,6 +134,7 @@ class KMPrintPosterView: KMBaseXibView {
         ])
         pageRangeComboBox.placeholderString = NSLocalizedString("e.g. 1,3-5,10", comment: "")
 
+        commentsFormsComboBox.removeAllItems()
         commentsFormsComboBox.addItems(withObjectValues: [
             NSLocalizedString("Document", comment: ""),
             NSLocalizedString("Document and Markups", comment: ""),
@@ -154,19 +153,18 @@ class KMPrintPosterView: KMBaseXibView {
         tableView.tabViewItem(at: 0).label = NSLocalizedString("Tile", comment: "")
         tableView.tabViewItem(at: 1).label = NSLocalizedString("Split", comment: "")
 
-        let paperArray = KMPageSizeTool.paperSize()
+        var paperArray = KMPrintPaperInfo.KMPaperType.allValues() /*KMPageSizeTool.paperSize()*/
         var tPaperArray = paperArray
-        tPaperArray.append(NSLocalizedString("Custom", comment: ""))
-
+        tPaperArray.removeFirst()
+        splitSizeComboBox.removeAllItems()
         splitSizeComboBox.addItems(withObjectValues: tPaperArray)
 
         var tFileArray = paperArray
-        tFileArray.insert(NSLocalizedString("Actual Size", comment: ""), at: 0)
-        tFileArray.append(NSLocalizedString("Custom", comment: ""))
-
+        filePageSizeBox.removeAllItems()
         filePageSizeBox.addItems(withObjectValues: tFileArray)
 
-        selectPerComboBox.addItems(withObjectValues: ["2", "4", "6", "9", "16", NSLocalizedString("Custom", comment: "")])
+        selectPerComboBox.removeAllItems()
+        selectPerComboBox.addItems(withObjectValues: KMPrintPageOperation.PageOfPaper.PageType.allValues())
     }
     
     override func reloadData() {
@@ -175,6 +173,302 @@ class KMPrintPosterView: KMBaseXibView {
         columnCountText.stringValue = "\(poster.pageOfPaper.point.x)"
         lineCountText.stringValue = "\(poster.pageOfPaper.point.y)"
     }
+    
+    
+    //MARK: Action
+    @IBAction func buttonItemClickCutMarks(_ sender: NSButton) {
+        self.viewModel.posterCutMarkAction(isSelect: cutMarksButton.state == .on, completion: { success, model in
+                
+        })
+    }
+
+    @IBAction func buttonItemClickLabels(_ sender: NSButton) {
+        self.viewModel.posterTagsAction(isSelect: cutMarksButton.state == .on, tags:[labelTextField.stringValue]) { success, model in
+            
+        }
+    }
+
+    @IBAction func buttonItemClickOrientation(_ sender: NSButton) {
+        var direction: KMPrintPaperDirectionType = .vertical
+        if landscapeButton.state == .on {
+            direction = .horizontal
+        } else if portraitButton.state == .on {
+            direction = .vertical
+        }
+        
+        self.viewModel.printDirectionAction(type: direction, completion: { success, model in
+            
+        })
+    }
+
+
+    @IBAction func comboBoxItemClickPageRange(_ sender: NSComboBox) {
+        var range: KMPrintPageRange = KMPrintPageRange()
+        if sender.indexOfSelectedItem == 0 ||
+            sender.indexOfSelectedItem == 1 || 
+            sender.indexOfSelectedItem == 2 {
+            window?.makeFirstResponder(self)
+            sender.isEditable = false
+            
+            if sender.indexOfSelectedItem == 0 {
+                range.type = .allPage
+            } else if sender.indexOfSelectedItem == 1 {
+                range.type = .oddPage
+            } else if sender.indexOfSelectedItem == 2 {
+                range.type = .evenPage
+            }
+        } else if sender.indexOfSelectedItem == 3 {
+            sender.stringValue = ""
+            sender.isEditable = true
+            window?.makeFirstResponder(sender)
+            
+            range.type = .custom
+            range.pageString = sender.stringValue
+        }
+        self.viewModel.pageRangeAction(range: range) { success, model in
+            
+        }
+    }
+
+    @IBAction func comboBoxItemClickSplitSize(_ sender: NSComboBox) {
+        overlapTextField.stringValue = "0"
+        var customSize = CGSize(width: 595, height: 842)
+//        self.PDFPrint.splitSize = CGSizeMake(tSize.width * 595.0/210, tSize.height * 842.0/297.0);
+        if splitSizeComboBox.indexOfSelectedItem == splitSizeComboBox.numberOfItems - 1 {
+            pageWidthTextField.isEnabled = true
+            pageHeightTextField.isEnabled = true
+        } else {
+            pageWidthTextField.isEnabled = false
+            pageHeightTextField.isEnabled = false
+        }
+
+        let type = KMPrintPaperInfo.KMPaperType(rawValue: sender.stringValue) ?? .A4
+        self.viewModel.printPaperTypeAction(type: type, customSize: customSize, completion: { success, model in
+            
+        })
+        
+    }
+
+    @IBAction func comboBoxItemClickFullPageSize(_ sender: NSComboBox) {
+        var customSize = CGSize(width: 595, height: 842)
+        if filePageSizeBox.indexOfSelectedItem == 0 {
+            paperWidthTextField.isEnabled = false
+            paperHeightTextField.isEnabled = false
+        } else if filePageSizeBox.indexOfSelectedItem == filePageSizeBox.numberOfItems - 1 {
+            paperWidthTextField.isEnabled = true
+            paperHeightTextField.isEnabled = true
+        } else {
+            paperWidthTextField.isEnabled = false
+            paperHeightTextField.isEnabled = false
+        }
+
+        overlapTextField.stringValue = "0"
+        let type = KMPrintPaperInfo.KMPaperType(rawValue: sender.stringValue) ?? .A4
+        self.viewModel.printPaperTypeAction(type: type, posterType: .breakUp, customSize: customSize, completion: { success, model in
+            
+        })
+    }
+
+    @IBAction func buttonItemClickReversePage(_ sender: NSButton) {
+        self.viewModel.printReverseAction(isSelect: reverseButton.state == .on) { success, model in
+            
+        }
+    }
+
+    @IBAction func comboBoxItemClickUnit(_ sender: Any) {
+        if unitComboBox.indexOfSelectedItem == 1 {
+            unitTLabel.stringValue = NSLocalizedString("mm", comment: "")
+            unitT1Label.stringValue = NSLocalizedString("mm", comment: "")
+            overlapUnit.stringValue = NSLocalizedString("mm", comment: "")
+        } else if unitComboBox.indexOfSelectedItem == 0 {
+            unitTLabel.stringValue = NSLocalizedString("cm", comment: "")
+            unitT1Label.stringValue = NSLocalizedString("cm", comment: "")
+            overlapUnit.stringValue = NSLocalizedString("cm", comment: "")
+        } else {
+            unitTLabel.stringValue = NSLocalizedString("cm", comment: "")
+            unitT1Label.stringValue = NSLocalizedString("cm", comment: "")
+            overlapUnit.stringValue = NSLocalizedString("in", comment: "")
+        }
+        
+        overlapTextField.stringValue = "0"
+        self.viewModel.printOverlapChangeAction(value: overlapTextField.floatValue, completion: { success, model in
+            
+        })
+    }
+
+    @IBAction func comboBoxItemClickCommentsForms(_ sender: NSComboBox) {
+        var type: KMPrintContentType = .document
+        if commentsFormsComboBox.indexOfSelectedItem == 0 {
+            type = .document
+        } else if commentsFormsComboBox.indexOfSelectedItem == 1 {
+            type = .documentAndMarkup
+        } else if commentsFormsComboBox.indexOfSelectedItem == 2 {
+            type = .documentAndStamp
+        }
+        
+        self.viewModel.printContentAction(type: type, completion: { success, model in
+            
+        })
+    }
+
+    @IBAction func comboBoxItemClickPagesPer(_ sender: NSComboBox) {
+        if selectPerComboBox.indexOfSelectedItem != 5 {
+            columnCountText.isEditable = false
+            lineCountText.isEditable = false
+            columnCountText.isSelectable = false
+            lineCountText.isSelectable = false
+        } else {
+            columnCountText.isEditable = true
+            lineCountText.isEditable = true
+            columnCountText.isSelectable = true
+            lineCountText.isSelectable = true
+        }
+        
+        self.viewModel.printPagePerChangeAction(type: KMPrintPageOperation.PageOfPaper.PageType(rawValue: selectPerComboBox.stringValue) ?? .page, completion: { success, model in
+            
+        })
+    }
+
+    func tabView(_ tabView: NSTabView, willSelect tabViewItem: NSTabViewItem?) {
+        overlapTextField.stringValue = "0"
+        self.viewModel.printOverlapChangeAction(value: overlapTextField.floatValue, completion: { success, model in
+            
+        })
+
+        if let identifier = tabViewItem?.identifier as? String {
+            if identifier == "1" {
+                self.viewModel.posterTypeAction(type: .tile) { success, model in
+                    
+                }
+            } else {
+                self.viewModel.posterTypeAction(type: .breakUp) { success, model in
+                    
+                }
+            }
+        }
+    }
+    
+    @objc func controlTextDidEndEditing(_ notification: Notification) {
+        guard let textField = notification.object as? NSTextField else {
+            return
+        }
+
+        if textField == scaleTextField {
+            if scaleTextField.integerValue <= 0 {
+                scaleTextField.stringValue = "100"
+            }
+            
+            self.viewModel.posterScaleAction(value: scaleTextField.floatValue / 100.0) { success, model in
+                
+            }
+        } else if textField == pageRangeComboBox {
+            
+            let range = KMPrintPageRange(type: .custom, pageString: pageRangeComboBox.stringValue)
+            self.viewModel.pageRangeAction(range: range) { success, model in
+                
+            }
+        } else if textField == columnCountText {
+            if selectPerComboBox.indexOfSelectedItem != 5 {
+                return
+            }
+            if columnCountText.integerValue < 1 {
+                columnCountText.stringValue = "1"
+            } else if columnCountText.integerValue > 99 {
+                columnCountText.stringValue = "99"
+            }
+            
+            let point = CGPoint(x: columnCountText.integerValue, y: lineCountText.integerValue)
+            self.viewModel.printPagePerChangeAction(type: .custom, customPoint: point) { success, model in
+                
+            }
+        } else if textField == lineCountText {
+            if selectPerComboBox.indexOfSelectedItem != 5 {
+                return
+            }
+
+            if lineCountText.integerValue < 1 {
+                lineCountText.stringValue = "1"
+            } else if lineCountText.integerValue > 99 {
+                lineCountText.stringValue = "99"
+            }
+            
+            
+            let point = CGPoint(x: columnCountText.integerValue, y: lineCountText.integerValue)
+            self.viewModel.printPagePerChangeAction(type: .custom, customPoint: point) { success, model in
+                
+            }
+        } else if textField == pageWidthTextField || textField == paperWidthTextField {
+            overlapTextField.stringValue = "0"
+            
+            var over = CGFloat((textField.stringValue as NSString).floatValue)
+            if unitComboBox.indexOfSelectedItem == 0 {
+                over *= 595.0 / 21
+            } else if unitComboBox.indexOfSelectedItem == 3 {
+                over *= 595.0 / 210 * 25.4
+            } else {
+                over *= 595.0 / 210
+            }
+            var size = self.viewModel.model.paper.info.size
+            size.width = over
+            self.viewModel.printPaperTypeAction(type: .custom, customSize: size, completion: { success, model in
+                
+            })
+            
+        } else if textField == pageHeightTextField || textField == paperHeightTextField {
+            overlapTextField.stringValue = "0"
+            self.viewModel.printOverlapChangeAction(value: overlapTextField.floatValue) { success, model in
+                
+            }
+            var over = CGFloat((textField.stringValue as NSString).floatValue)
+            if unitComboBox.indexOfSelectedItem == 0 {
+                over *= 842.0 / 29.7
+            } else if unitComboBox.indexOfSelectedItem == 3 {
+                over *= 842.0 / 297 * 25.4
+            } else {
+                over *= 842.0 / 297
+            }
+            var size = self.viewModel.model.paper.info.size
+            size.width = over
+            self.viewModel.printPaperTypeAction(type: .custom, customSize: size, completion: { success, model in
+                
+            })
+        }
+    }
+
+    @objc func controlTextDidChange(_ notification: Notification) {
+        guard let textField = notification.object as? NSTextField else {
+            return
+        }
+
+        if textField == columnCountText || textField == lineCountText {
+            if let string = textField.formatter?.string(for: NSNumber(value: textField.stringValue.stringToCGFloat())) {
+                textField.stringValue = string
+            }
+        } else if textField == overlapTextField {
+            var maxOverlap: CGFloat
+            let size = self.viewModel.model.paper.info.size
+            maxOverlap = min(size.width, size.height)
+
+            var over = textField.stringValue.stringToCGFloat()
+            if unitComboBox.indexOfSelectedItem == 0 {
+                over *= 28.4
+            } else if unitComboBox.indexOfSelectedItem == 3 {
+                over *= 72.0
+            } else {
+                over *= 2.84 // 595/210
+            }
+
+            if over <= 0 || over > maxOverlap / 2 {
+                overlapTextField.stringValue = "0"
+                over = 0
+            }
+            
+            self.viewModel.printOverlapChangeAction(value: Float(over)) { success, model in
+                
+            }
+        }
+    }
+
 }
 
 

+ 33 - 0
PDF Office/PDF Master/Class/PDFTools/Print/View/PrintSettingView/View/Poster/KMPrintPosterView.xib

@@ -77,6 +77,9 @@
                                     <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
                                     <font key="font" metaFont="system"/>
                                 </buttonCell>
+                                <connections>
+                                    <action selector="buttonItemClickOrientation:" target="-2" id="0Vy-q2-VmY"/>
+                                </connections>
                             </button>
                             <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="bne-3g-9YL">
                                 <rect key="frame" x="8" y="-1" width="93" height="18"/>
@@ -84,6 +87,9 @@
                                     <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
                                     <font key="font" metaFont="system"/>
                                 </buttonCell>
+                                <connections>
+                                    <action selector="buttonItemClickOrientation:" target="-2" id="LDM-KT-5OH"/>
+                                </connections>
                             </button>
                         </subviews>
                         <constraints>
@@ -112,6 +118,9 @@
                             <string>in</string>
                         </objectValues>
                     </comboBoxCell>
+                    <connections>
+                        <action selector="comboBoxItemClickUnit:" target="-2" id="ViO-wk-7F9"/>
+                    </connections>
                 </comboBox>
                 <tabView translatesAutoresizingMaskIntoConstraints="NO" id="aT9-yf-HZu">
                     <rect key="frame" x="9" y="306" width="613" height="102"/>
@@ -140,6 +149,9 @@
                                             <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
                                             <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                         </comboBoxCell>
+                                        <connections>
+                                            <action selector="comboBoxItemClickSplitSize:" target="-2" id="MlI-2b-fUx"/>
+                                        </connections>
                                     </comboBox>
                                     <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="huG-r2-MIm">
                                         <rect key="frame" x="-2" y="3" width="67" height="16"/>
@@ -265,6 +277,9 @@
                                             <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
                                             <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                         </comboBoxCell>
+                                        <connections>
+                                            <action selector="comboBoxItemClickFullPageSize:" target="-2" id="8xX-i4-CpN"/>
+                                        </connections>
                                     </comboBox>
                                     <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="zbj-AU-tDW">
                                         <rect key="frame" x="-2" y="3" width="106" height="16"/>
@@ -284,6 +299,9 @@
                                             <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
                                             <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                         </comboBoxCell>
+                                        <connections>
+                                            <action selector="comboBoxItemClickPagesPer:" target="-2" id="ZRF-Vj-7Py"/>
+                                        </connections>
                                     </comboBox>
                                     <textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="svz-MK-Cyc">
                                         <rect key="frame" x="207" y="0.0" width="30" height="21"/>
@@ -410,6 +428,9 @@
                                     <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
                                     <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                 </comboBoxCell>
+                                <connections>
+                                    <action selector="comboBoxItemClickPageRange:" target="-2" id="V1d-ua-uhc"/>
+                                </connections>
                             </comboBox>
                         </subviews>
                         <constraints>
@@ -434,6 +455,9 @@
                                     <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
                                     <font key="font" metaFont="system"/>
                                 </buttonCell>
+                                <connections>
+                                    <action selector="buttonItemClickCutMarks:" target="-2" id="3pY-5e-pnO"/>
+                                </connections>
                             </button>
                             <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="yh0-n2-HXE">
                                 <rect key="frame" x="8" y="32" width="66" height="18"/>
@@ -441,6 +465,9 @@
                                     <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
                                     <font key="font" metaFont="system"/>
                                 </buttonCell>
+                                <connections>
+                                    <action selector="buttonItemClickLabels:" target="-2" id="DaQ-ir-0zi"/>
+                                </connections>
                             </button>
                             <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="dNz-66-9JH">
                                 <rect key="frame" x="8" y="2" width="128" height="16"/>
@@ -467,6 +494,9 @@
                                     <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
                                     <font key="font" metaFont="system"/>
                                 </buttonCell>
+                                <connections>
+                                    <action selector="buttonItemClickReversePage:" target="-2" id="QPJ-Ph-p8R"/>
+                                </connections>
                             </button>
                             <comboBox focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="yQR-GS-Lxb">
                                 <rect key="frame" x="138" y="-2" width="244" height="23"/>
@@ -478,6 +508,9 @@
                                     <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
                                     <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                 </comboBoxCell>
+                                <connections>
+                                    <action selector="comboBoxItemClickCommentsForms:" target="-2" id="TAS-67-ECJ"/>
+                                </connections>
                             </comboBox>
                             <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="49t-aX-aKI">
                                 <rect key="frame" x="8" y="116" width="55" height="16"/>

+ 58 - 8
PDF Office/PDF Master/Class/PDFTools/Print/View/PrintSettingView/ViewModel/KMPrintViewModel.swift

@@ -24,11 +24,6 @@ extension KMPrintViewModel {
         completion(true, model)
     }
     
-    //打印纸张大小设置
-    func paperSetAction(info: KMPrintPaperInfo, completion: KMPrintViewModelCompletion) {
-        completion(true, model)
-    }
-    
     //打印份数
     func paperCopiesAction(copies: Int, completion: KMPrintViewModelCompletion) {
         model.printer.copies = copies
@@ -87,12 +82,67 @@ extension KMPrintViewModel {
         completion(true, model)
     }
     
-    /**
-     打印模式
-     */
+    //打印页面偏移
+    func printOverlapChangeAction(value: Float, completion: KMPrintViewModelCompletion) {
+        self.model.page.operation.poster.overlap = value
+        
+        completion(true, model)
+    }
+    
+    //打印模式
     func printDealModelAction(data: KMPrintPageOperation, completion: KMPrintViewModelCompletion) {
         self.model.page.operation = data
         
         completion(true, model)
     }
+    
+    //纸张类型
+    func printPaperTypeAction(type: KMPrintPaperInfo.KMPaperType, posterType: KMPrintPageOperation.Poster.PosterType = .tile, customSize: CGSize = CGSizeZero, completion: KMPrintViewModelCompletion) {
+        self.model.page.operation.poster.overlap = 0
+        self.model.page.operation.poster.type = posterType
+        self.model.paper.info.type = type
+        self.model.paper.info.customSize = customSize
+        
+        let size = self.model.paper.info.size
+        let multiple = max(size.width, size.height) / 842
+        
+        self.model.paper.info.inset = NSEdgeInsets(top: 50 * multiple, left: 60 * multiple, bottom: 50 * multiple, right: 60 * multiple)
+        
+        completion(true, model)
+    }
+    
+    func printPagePerChangeAction(type: KMPrintPageOperation.PageOfPaper.PageType, customPoint: CGPoint = CGPoint(x: 2, y: 2), completion: KMPrintViewModelCompletion) {
+        self.model.page.operation.poster.pageOfPaper.type = type
+        self.model.page.operation.poster.pageOfPaper.point = customPoint
+        
+        completion(true, model)
+    }
+}
+
+//Poster
+extension KMPrintViewModel {
+    func posterCutMarkAction(isSelect: Bool, completion: KMPrintViewModelCompletion) {
+        self.model.page.operation.poster.isCutMark = isSelect
+        
+        completion(true, model)
+    }
+    
+    func posterTagsAction(isSelect: Bool, tags: [String], completion: KMPrintViewModelCompletion) {
+        self.model.page.operation.poster.isTags = isSelect
+        self.model.page.operation.poster.tags = tags
+        
+        completion(true, model)
+    }
+    
+    func posterTypeAction(type: KMPrintPageOperation.Poster.PosterType, completion: KMPrintViewModelCompletion) {
+        self.model.page.operation.poster.type = type
+        
+        completion(true, model)
+    }
+    
+    func posterScaleAction(value: Float, completion: KMPrintViewModelCompletion) {
+        self.model.page.operation.poster.scale = CGFloat(value)
+        
+        completion(true, model)
+    }
 }

+ 2 - 1
PDF Office/PDF Master/Class/PDFTools/Watermark/Tools/KMWatermarkManager.swift

@@ -81,7 +81,8 @@ class KMWatermarkManager: NSObject {
     
     func addWatermark(watermark: KMWatermarkModel) -> Bool {
         if (!FileManager.default.fileExists(atPath: watermarkFolderPath!)) {
-            let create = try?FileManager.default.createDirectory(atPath: watermarkFolderPath!, withIntermediateDirectories: false)
+//            let create = try?FileManager.default.createDirectory(atPath: watermarkFolderPath!, withIntermediateDirectories: false)
+            let create: ()? = try?FileManager.default.createDirectory(atPath: watermarkFolderPath!, withIntermediateDirectories: true, attributes: nil)
             if (create == nil) {
                 return false
             }