|
@@ -1198,6 +1198,25 @@ extension KMEditPDfHanddler {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
if areas.count == 1 {
|
|
if areas.count == 1 {
|
|
|
|
+ if KMTools.isPDFType(format) {
|
|
|
|
+ guard let image = areas.first!.thumbnailImage else {
|
|
|
|
+ NSSound.beep()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ let pdfdocument = CPDFDocument()
|
|
|
|
+ pdfdocument?.km_insert(image: image, at: 0)
|
|
|
|
+ let savePanel = NSSavePanel()
|
|
|
|
+ savePanel.allowedFileTypes = ["pdf"]
|
|
|
|
+ savePanel.beginSheetModal(for: self.viewC!.view.window!) { response in
|
|
|
|
+ if (response != .OK) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if let data = pdfdocument?.write(to: savePanel.url!), data {
|
|
|
|
+ NSWorkspace.shared.selectFile(savePanel.url?.path, inFileViewerRootedAtPath: "");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+ }
|
|
let panel = NSSavePanel()
|
|
let panel = NSSavePanel()
|
|
panel.nameFieldStringValue = "\(NSLocalizedString("Untitled", comment: "")).\(format)"
|
|
panel.nameFieldStringValue = "\(NSLocalizedString("Untitled", comment: "")).\(format)"
|
|
panel.isExtensionHidden = true
|
|
panel.isExtensionHidden = true
|
|
@@ -1240,9 +1259,20 @@ extension KMEditPDfHanddler {
|
|
outPath = outPath.stringByAppendingPathComponent(documentFileName)
|
|
outPath = outPath.stringByAppendingPathComponent(documentFileName)
|
|
outPath = outPath + "_page\(pageIndex+1)_\(j+1)"
|
|
outPath = outPath + "_page\(pageIndex+1)_\(j+1)"
|
|
outPath = outPath.stringByAppendingPathExtension(format)
|
|
outPath = outPath.stringByAppendingPathExtension(format)
|
|
- let result = self.listView?.extractImage(with: areas[j], toImagePath: outPath) ?? false
|
|
|
|
- if result {
|
|
|
|
- saveURLs.append(URL(fileURLWithPath: outPath))
|
|
|
|
|
|
+ if KMTools.isPDFType(format) {
|
|
|
|
+ if let image = areas[j].thumbnailImage {
|
|
|
|
+ let pdfdocument = CPDFDocument()
|
|
|
|
+ pdfdocument?.km_insert(image: image, at: 0)
|
|
|
|
+ let suc = pdfdocument?.write(toFile: outPath) ?? false
|
|
|
|
+ if suc {
|
|
|
|
+ saveURLs.append(URL(fileURLWithPath: outPath))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ let result = self.listView?.extractImage(with: areas[j], toImagePath: outPath) ?? false
|
|
|
|
+ if result {
|
|
|
|
+ saveURLs.append(URL(fileURLWithPath: outPath))
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
NSWorkspace.shared.activateFileViewerSelecting(saveURLs)
|
|
NSWorkspace.shared.activateFileViewerSelecting(saveURLs)
|