Browse Source

【编辑PDF】图片导出要增加支持png和pdf,目前只支持jpg

lizhe 9 months ago
parent
commit
d12c9fca8d

+ 8 - 1
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -168,6 +168,11 @@ extension KMMainViewController {
     
     func exportImageArea()->NSMenuItem {
         let exportItem = NSMenuItem(title: NSLocalizedString("Export", comment: ""), action: #selector(menuItemEditingClick_ExportImage), target: self)
+        let menu = NSMenu()
+        let item1 = menu.insertItem(withTitle: NSLocalizedString("PNG", comment: ""), action:#selector(exportStampImage), target: self, tag:0, at: 0)
+        let item2 = menu.insertItem(withTitle: NSLocalizedString("JPG", comment: ""), action:#selector(exportCorpImage), target: self, tag:1, at: 1)
+        let item3 = menu.insertItem(withTitle: NSLocalizedString("PDF", comment: ""), action:#selector(exportStampImage), target: self, tag:2, at: 2)
+        exportItem.submenu = menu
         return exportItem
     }
     
@@ -1620,12 +1625,14 @@ extension KMMainViewController {
     
     
     @objc func exportStampImage(sender:NSMenuItem) {
-        if listView.activeAnnotation != nil && ((listView.activeAnnotation is CPDFStampAnnotation) || (listView.activeAnnotation is CPDFSignatureAnnotation)) {
+        if listView.activeAnnotation != nil && ((listView.activeAnnotation is CPDFStampAnnotation) || (listView.activeAnnotation is CPDFSignatureAnnotation)) || (self.listView.selectImageAreas != nil) {
             var image : NSImage = NSImage()
             if (listView.activeAnnotation is CPDFStampAnnotation) {
                 image = (listView.activeAnnotation as! CPDFStampAnnotation).stampImage()
             } else if (listView.activeAnnotation is CPDFSignatureAnnotation) {
                 image = (listView.activeAnnotation as! CPDFSignatureAnnotation).signImage
+            } else {
+                image = self.listView.selectImageAreas.thumbnailImage(with: CGSize(width: 1920, height: 1920)) ?? NSImage()
             }
             let data = image.tiffRepresentation
             if sender.tag == 0 {