KMBatchOperateImageToPDFViewController.swift 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. //
  2. // KMBatchOperateImageToPDFViewController.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by liujiajie on 2023/12/5.
  6. //
  7. import Cocoa
  8. class KMBatchOperateImageToPDFViewController: KMBatchOperateBaseViewController, KMImageToPDFMethodDelegate, NSPopoverDelegate{
  9. @IBOutlet var outputTypeLabel: NSTextField!
  10. @IBOutlet var createNewPDFBtn: NSButton!
  11. @IBOutlet var btnMerge: NSButton!
  12. @IBOutlet var appendPDFBtn: NSButton!
  13. @IBOutlet var appendTextField: NSTextField!
  14. @IBOutlet var appendOtherPDFBtn: NSButton!
  15. @IBOutlet var appendBackView: NSView!
  16. @IBOutlet var ocrLabel: NSTextField!
  17. @IBOutlet var ocrSelectBtn: NSButton!
  18. @IBOutlet var languaeBox: NSBox!
  19. @IBOutlet var languageButton: NSButton!
  20. @IBOutlet var saveAsButton: NSButton!
  21. @IBOutlet var planButton: NSButton!
  22. @IBOutlet var selectLanguageLabel: NSTextField!
  23. @IBOutlet var planBox: NSBox!
  24. @IBOutlet var actionButton: NSButton!
  25. var password: String = ""
  26. lazy var method: KMImageToPDFMethod = {
  27. let method = KMImageToPDFMethod()
  28. method.imageTopdfDelegate = self
  29. return method
  30. }()
  31. override var interfaceStatus: KMBatchOperateInterfaceStatus?{
  32. set{
  33. super.interfaceStatus = newValue
  34. if newValue == .PrepareProcess {
  35. DispatchQueue.main.asyncAfter(deadline: .now() + 0.4) {
  36. let files = NSMutableArray()
  37. for url in self.successFilePathURLArray! {
  38. if FileManager.default.fileExists(atPath: url.path) {
  39. files.add(url)
  40. }
  41. }
  42. if files.count > 0 {
  43. let workspace = NSWorkspace.shared
  44. workspace.activateFileViewerSelecting(files as! [URL])
  45. }
  46. }
  47. self.actionButton.tag = 1
  48. self.actionButton.title = NSLocalizedString("Save as PDF", comment: "")
  49. self.actionButton.setTitleColor(KMAppearance.Layout.w0Color())
  50. self.actionButton.isEnabled = true
  51. self.actionButton.layer?.backgroundColor = KMAppearance.Interactive.m0Color().cgColor
  52. } else {
  53. self.actionButton.tag = 0
  54. self.actionButton.layer?.backgroundColor = KMAppearance.Interactive.m0Color().cgColor
  55. self.actionButton.setTitleColor(KMAppearance.Layout.w0Color())
  56. self.actionButton.isEnabled = false
  57. }
  58. }
  59. get{
  60. return super.interfaceStatus
  61. }
  62. }
  63. deinit {
  64. NotificationCenter.default.removeObserver(self)
  65. DistributedNotificationCenter.default().removeObserver(self)
  66. }
  67. override func viewDidLoad() {
  68. super.viewDidLoad()
  69. self.localizedLanguage()
  70. self.configuUI()
  71. NotificationCenter.default.addObserver(self, selector: #selector(OCRSelectedLanguagesChangeNotification(notification:)), name: NSNotification.Name("KMOCRSelectedLanguagesChangeNotification"), object: nil)
  72. NotificationCenter.default.addObserver(self, selector: #selector(OCRSelectedPlanChangeNotification(notification:)), name: NSNotification.Name("KMOCRSelectedPlanChangeNotification"), object: nil)
  73. // NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
  74. DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
  75. NotificationCenter.default.addObserver(self, selector: #selector(batchFilesCountNotification(notification:)), name: NSNotification.Name("KMBatchFilesCountNotification"), object: nil)
  76. }
  77. func localizedLanguage() {
  78. self.outputTypeLabel.stringValue = KMLocalizedString("Output",nil)
  79. self.btnMerge.title = KMLocalizedString("Merge All", nil)
  80. self.createNewPDFBtn.title = KMLocalizedString("New PDF Document", nil)
  81. self.appendPDFBtn.title = KMLocalizedString("Append To Existing File", nil)
  82. self.appendTextField.placeholderString = KMLocalizedString("Select a File", nil)
  83. self.selectLanguageLabel.stringValue = KMLocalizedString("Select OCR Language:",nil)
  84. self.ocrSelectBtn.title = KMLocalizedString("OCR Plan",nil)
  85. self.updateLanguageButton((KMGOCRManager.default().selectedLanguages?.value(forKeyPath: KMGOCRLanguageStringKey) as? [String]))
  86. self.actionButton.title = KMLocalizedString("Save as PDF", nil)
  87. self.saveAsButton.title = KMLocalizedString("Save as TXT", nil)
  88. self.OCRSelectedPlanChangeAction()
  89. }
  90. func configuUI() {
  91. self.view.wantsLayer = true
  92. appendOtherPDFBtn.wantsLayer = true
  93. appendBackView.wantsLayer = true
  94. appendBackView.layer?.borderWidth = 0.5
  95. self.actionButton.wantsLayer = true
  96. self.actionButton.layer?.backgroundColor = KMAppearance.Interactive.m0Color().cgColor
  97. self.appendOtherPDFBtn.layer?.backgroundColor = KMAppearance.Interactive.s0Color().withAlphaComponent(0.4).cgColor
  98. self.actionButton.setTitleColor(KMAppearance.Layout.w0Color())
  99. self.actionButton.layer?.cornerRadius = 1.0
  100. self.createNewPDFBtn.setTitleColor(KMAppearance.Layout.h0Color())
  101. self.btnMerge.setTitleColor(KMAppearance.Layout.h0Color())
  102. self.appendPDFBtn.setTitleColor(KMAppearance.Layout.h0Color())
  103. self.ocrSelectBtn.setTitleColor(KMAppearance.Layout.h0Color())
  104. self.saveAsButton.setTitleColor(KMAppearance.Layout.h0Color())
  105. self.selectLanguageLabel.textColor = KMAppearance.Layout.h0Color()
  106. self.languageButton.isEnabled = false
  107. self.planButton.isEnabled = false
  108. self.saveAsButton.isEnabled = false
  109. appendTextField.backgroundColor = KMAppearance.Layout.l1Color()
  110. planButton.wantsLayer = true
  111. appendTextField.wantsLayer = true
  112. planButton.wantsLayer = true
  113. appendTextField.layer?.cornerRadius = 1.0
  114. languageButton.layer?.backgroundColor = NSColor.clear.cgColor
  115. languaeBox.borderColor = KMAppearance.Interactive.s0Color()
  116. planBox.borderColor = KMAppearance.Interactive.s0Color()
  117. languaeBox.fillColor = KMAppearance.Layout.l1Color()
  118. planBox.fillColor = KMAppearance.Layout.l1Color()
  119. self.updateViewColor()
  120. }
  121. func updateViewColor() {
  122. if KMAppearance.isDarkMode() {
  123. self.view.layer?.backgroundColor = NSColor(red: 0.055, green: 0.067, blue: 0.078, alpha: 1).cgColor
  124. appendBackView.layer?.borderColor = NSColor(red: 86/255.0, green: 88/255.0, blue: 90/255.0, alpha: 1).cgColor
  125. appendBackView.layer?.backgroundColor = NSColor(red: 57/255.0, green: 60/255.0, blue: 62/255.0, alpha: 1).cgColor
  126. } else {
  127. self.view.layer?.backgroundColor = NSColor(red: 0.922, green: 0.925, blue: 0.941, alpha: 1).cgColor
  128. appendBackView.layer?.borderColor = NSColor(red: 218/255.0, green: 219/255.0, blue: 222/255.0, alpha: 1).cgColor
  129. appendBackView.layer?.backgroundColor = NSColor.white.cgColor;
  130. }
  131. }
  132. func updateLanguageButton(_ languages: [String]?) {
  133. if languages?.count ?? 0 < 1 {
  134. self.languageButton.title = " " + KMLocalizedString("Auto Detection", nil)
  135. return
  136. }
  137. var languageName: String = ""
  138. if languages?.count ?? 0 > 0 {
  139. for i in 0..<(languages?.count ?? 0) {
  140. let language = languages?[i]
  141. if i == 0 {
  142. languageName = language ?? ""
  143. } else {
  144. languageName = languageName.appendingFormat(",%@", language ?? "")
  145. }
  146. }
  147. } else {
  148. languageName = ""
  149. }
  150. self.languageButton.title = " " + languageName
  151. }
  152. func converArrType(arr: Array<KMBatchOperateFile>, keyString: String) -> [String] {
  153. let newArr = NSMutableArray()
  154. for item in arr {
  155. newArr.add(item.filePath)
  156. }
  157. return newArr as! [String]
  158. }
  159. func isConnectionAvailable() -> Bool {
  160. // var isExistenceNetwork = true
  161. // let reach = Reachability(hostname: "www.apple.com")
  162. // let status: NetworkStatus = NetworkStatus(rawValue: (reach?.currentReachabilityStatus())!.rawValue)
  163. // switch status.rawValue {
  164. // case 0:
  165. // isExistenceNetwork = false
  166. // case 1:
  167. // isExistenceNetwork = true
  168. // case 2:
  169. // isExistenceNetwork = true
  170. // default:
  171. // break
  172. // }
  173. if Reachability.forInternetConnection().currentReachabilityStatus().rawValue == 0 {
  174. return false
  175. }
  176. return true
  177. }
  178. func beginImageToPDF() {
  179. if self.files?.count ?? 0 < 1 {
  180. return
  181. }
  182. let photoArray = converArrType(arr: self.files!, keyString: "")
  183. var path: String = ""
  184. var isMerge = false
  185. var isCreatNewPDF = false
  186. var isOCR = false
  187. if self.ocrSelectBtn.state == .on {
  188. isOCR = true
  189. }
  190. var isSaveAs = false
  191. if self.saveAsButton.state == .on {
  192. isSaveAs = true
  193. }
  194. let plan = UserDefaults.standard.integer(forKey: "KMOCRCurrentPlanKey")
  195. if isOCR && !self.isConnectionAvailable() && plan == 0 {
  196. let alert = NSAlert()
  197. alert.alertStyle = .critical
  198. alert.messageText = NSLocalizedString("Connection Error", comment: "")
  199. alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
  200. alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
  201. if alert.responds(to: #selector(alert.beginSheetModal(for:completionHandler:))) {
  202. alert.beginSheetModal(for: self.view.window!, completionHandler: nil)
  203. } else {
  204. alert.runModal()
  205. }
  206. return
  207. }
  208. if self.createNewPDFBtn.state == .on {
  209. if (self.choosePath.count < 1) {
  210. let alert = NSAlert()
  211. alert.alertStyle = .critical
  212. alert.messageText = String(format: NSLocalizedString("Output Folder cannot be empty.", comment: ""))
  213. alert.runModal()
  214. return
  215. }
  216. path = self.choosePath
  217. if self.btnMerge.state == .on {
  218. isMerge = true
  219. }
  220. isCreatNewPDF = true
  221. } else {
  222. let appenString = self.appendTextField.stringValue
  223. if appenString.isEmpty {
  224. let alert = NSAlert()
  225. alert.alertStyle = .critical
  226. alert.messageText = String(format: NSLocalizedString("Select a File", comment: ""))
  227. alert.runModal()
  228. return
  229. }
  230. path = self.appendTextField.stringValue
  231. isMerge = true
  232. isCreatNewPDF = false
  233. }
  234. self.languageButton.isEnabled = false
  235. self.planButton.isEnabled = false
  236. self.method.password = self.password
  237. self.interfaceStatus = .Processing
  238. self.method.exportPDFFile(fileArray: photoArray, savePath: path, isOCR: isOCR, isCreatPDF: isCreatNewPDF, isMerge: isMerge, isSaveAsText: isSaveAs) { [weak self] savePath, errorArr, errorOCRArray in
  239. self?.languageButton.isEnabled = true
  240. self?.planButton.isEnabled = true
  241. self?.interfaceStatus = .PrepareProcess
  242. if errorArr.count > 0 {
  243. let dict: [String: Any] = ["isMerge": false, "isSuccess": false]
  244. NotificationCenter.default.post(name: NSNotification.Name(rawValue: "KMBatchOperateImageToPDFSuccessNotification"), object: self, userInfo: dict)
  245. let alert = NSAlert()
  246. alert.messageText = NSLocalizedString("Conversion Failed", comment: "")
  247. alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
  248. alert.informativeText = "\(errorArr)"
  249. alert.alertStyle = .informational
  250. alert.runModal()
  251. } else {
  252. if errorOCRArray.count > 0 {
  253. var contextString = NSLocalizedString("Some problems occurred during the last operation:", comment: "")
  254. for filePath in errorOCRArray {
  255. contextString += "\n" + (filePath as AnyObject).lastPathComponent
  256. }
  257. let alert = NSAlert()
  258. alert.messageText = NSLocalizedString("Converted Successfully", comment: "")
  259. alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
  260. alert.informativeText = contextString
  261. alert.alertStyle = .informational
  262. let response = alert.runModal()
  263. if response == .OK {
  264. self?.viewFileAtFinder(fileName: savePath)
  265. }
  266. } else {
  267. self?.viewFileAtFinder(fileName: savePath)
  268. }
  269. }
  270. }
  271. }
  272. func viewFileAtFinder(fileName: String) {
  273. let dict = ["isMerge": true, "isSuccess": true]
  274. NotificationCenter.default.post(name: Notification.Name("KMBatchOperateImageToPDFSuccessNotification"), object: self, userInfo: dict)
  275. let workspace = NSWorkspace.shared
  276. let url = URL(fileURLWithPath: fileName)
  277. workspace.activateFileViewerSelecting([url])
  278. }
  279. //MARK: Notification
  280. @objc func OCRSelectedLanguagesChangeNotification(notification: Notification) {
  281. let selectedLanguages = notification.object/* as? [KMBatchOperateFile]*/
  282. self.updateLanguageButton(selectedLanguages as? [String])
  283. }
  284. @objc func OCRSelectedPlanChangeNotification(notification: Notification) {
  285. self.OCRSelectedPlanChangeAction()
  286. }
  287. @objc func themeChanged(notification: Notification) {
  288. DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
  289. self.updateViewColor()
  290. }
  291. }
  292. func OCRSelectedPlanChangeAction() {
  293. let plan = UserDefaults.standard.integer(forKey: "KMOCRCurrentPlanKey")
  294. if plan == 0 {
  295. self.planButton.title = " " + KMLocalizedString("Plan 1 (Online)", nil)
  296. } else {
  297. self.planButton.title = " " + KMLocalizedString("Plan 2 (Offline)", nil)
  298. }
  299. KMGOCRManager.default().selectedLanguages = NSMutableArray()
  300. self.updateLanguageButton(KMGOCRManager.default().selectedLanguages?.value(forKeyPath: KMGOCRLanguageStringKey) as? [String])
  301. }
  302. @objc func batchFilesCountNotification(notification: Notification) {
  303. let files: Array? = notification.object as? [KMBatchOperateFile]
  304. self.files? = files ?? []
  305. // if files?.count ?? 0 > 0 {
  306. // haveFiles = true
  307. // } else {
  308. // haveFiles = false
  309. // }
  310. }
  311. @IBAction func buttonClicked_CreateNewPDF(_ sender: NSButton) {
  312. if (sender.state == .on) {
  313. self.btnMerge.isEnabled = true
  314. self.appendPDFBtn.state = .off
  315. self.appendOtherPDFBtn.isEnabled = false
  316. }
  317. }
  318. @IBAction func buttonClicked_AppendOtherPDF(_ sender: NSButton) {
  319. if (sender.state == .on) {
  320. self.createNewPDFBtn.state = .off
  321. self.btnMerge.isEnabled = false
  322. self.appendOtherPDFBtn.isEnabled = true
  323. }
  324. }
  325. @IBAction func buttonClicked_OCRSelect(_ sender: NSButton) {
  326. //MARK: 判断是否付费用户
  327. if IAPProductsManager.default().isAvailableAllFunction() == false {
  328. KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
  329. self.ocrSelectBtn.state = .off
  330. return
  331. }
  332. if (sender.state == .on) {
  333. self.languageButton.isEnabled = true
  334. self.planButton.isEnabled = true
  335. self.saveAsButton.isEnabled = true
  336. } else {
  337. self.languageButton.isEnabled = false
  338. self.planButton.isEnabled = false
  339. self.saveAsButton.isEnabled = false
  340. }
  341. }
  342. @IBAction func buttonClicked_ChooseLanguage(_ sender: NSButton) {
  343. let plan = UserDefaults.standard.integer(forKey: "KMOCRCurrentPlanKey")
  344. if plan == 0 {
  345. KMGOCRManager.default().ocrType = .google
  346. } else {
  347. KMGOCRManager.default().ocrType = .apple
  348. }
  349. let popover = NSPopover()
  350. popover.delegate = self
  351. popover.contentViewController = KMLanguageViewController(nibName: "KMLanguageViewController", bundle: Bundle.main)
  352. popover.animates = true
  353. popover.behavior = .transient
  354. popover.show(relativeTo: sender.bounds, of: sender as NSView, preferredEdge: .minX)
  355. }
  356. @IBAction func buttonClicked_ChoosePlan(_ sender: NSButton) {
  357. let popover = NSPopover()
  358. popover.delegate = self
  359. popover.contentViewController = KMPlanViewController(nibName: "KMPlanViewController", bundle: Bundle.main)
  360. popover.animates = true
  361. popover.behavior = .transient
  362. popover.show(relativeTo: sender.bounds, of: sender as NSView, preferredEdge: .minX)
  363. }
  364. @IBAction func buttonClicked_ImageToPDF(_ sender: NSButton) {
  365. //MARK: 判断是否付费用户,展示iap界面
  366. if self.files?.count ?? 0 < 1 {
  367. return
  368. }
  369. if IAPProductsManager.default().isAvailableAllFunction() == false && self.files?.count ?? 0 > 1{
  370. KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
  371. return
  372. }
  373. if sender.tag == 1 {
  374. self.choosePath = ""
  375. var hasTask = false
  376. for i in 0..<(self.files?.count ?? 0) {
  377. let file = self.files?[i]
  378. file?.currentOperateInfo?.resetState()
  379. if file?.fileType == .Image {
  380. hasTask = true
  381. }
  382. }
  383. if !hasTask {
  384. NSSound.beep()
  385. return
  386. }
  387. var isOCR = false
  388. if self.ocrSelectBtn.state == .on {
  389. isOCR = true
  390. }
  391. var isSaveAs = false
  392. if self.saveAsButton.state == .on {
  393. isSaveAs = true
  394. }
  395. let plan = UserDefaults.standard.integer(forKey: "KMOCRCurrentPlanKey")
  396. if isOCR && !isConnectionAvailable() && plan == 0 {
  397. let alert = NSAlert()
  398. alert.alertStyle = .critical
  399. alert.messageText = NSLocalizedString("Connection Error", comment: "")
  400. alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
  401. alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
  402. if let window = self.view.window {
  403. alert.beginSheetModal(for: window, completionHandler: nil)
  404. } else {
  405. alert.runModal()
  406. }
  407. return
  408. }
  409. if self.createNewPDFBtn.state == .off {
  410. let appenString = self.appendTextField.stringValue
  411. if appenString.isEmpty {
  412. let alert = NSAlert()
  413. alert.alertStyle = .critical
  414. alert.messageText = NSLocalizedString("Select a File", comment: "")
  415. alert.runModal()
  416. return
  417. }
  418. }
  419. let openPanel = NSOpenPanel()
  420. openPanel.canChooseFiles = false
  421. openPanel.canChooseDirectories = true
  422. openPanel.canCreateDirectories = true
  423. openPanel.beginSheetModal(for: self.view.window!) { (result) in
  424. if result == .OK {
  425. for fileURL in openPanel.urls {
  426. self.choosePath = fileURL.path
  427. self.beginImageToPDF()
  428. }
  429. }
  430. }
  431. } else { // Do something else }
  432. }
  433. }
  434. @IBAction func buttonItemClicked_AppendOtherPDF(_ sender: NSButton) {
  435. let openPanel = NSOpenPanel()
  436. openPanel.allowedFileTypes = ["pdf"]
  437. openPanel.canChooseDirectories = false
  438. openPanel.allowsMultipleSelection = false
  439. openPanel.beginSheetModal(for: self.view.window!) { (result) in
  440. if result == .OK {
  441. guard let url = openPanel.url else { return }
  442. guard let document = PDFDocument(url: url) else {
  443. let alert = NSAlert()
  444. alert.alertStyle = .critical
  445. alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
  446. alert.runModal()
  447. return
  448. }
  449. if !document.allowsCopying || !document.allowsPrinting {
  450. let alert = NSAlert()
  451. alert.alertStyle = .critical
  452. alert.messageText = NSLocalizedString("This is a secured document. Editing is not permitted.", comment: "")
  453. alert.runModal()
  454. return
  455. }
  456. if document.isLocked {
  457. KMBaseWindowController.checkPassword(url: url, type: .owner) { [weak self] success, resultPassword in
  458. if success {
  459. self?.password = resultPassword
  460. self?.appendTextField.stringValue = url.path
  461. }
  462. }
  463. } else {
  464. self.appendTextField.stringValue = url.path
  465. }
  466. }
  467. }
  468. }
  469. @IBAction func buttonClicked_Help(_ sender: NSButton) {
  470. let helpController = NSViewController()
  471. let textView = NSTextView(frame: NSRect(x: 0, y: 0, width: 300.0, height: 100.0))
  472. textView.backgroundColor = NSColor.clear
  473. textView.isEditable = false
  474. textView.layer?.cornerRadius = 6
  475. let tStrAuto = NSLocalizedString("Choose automatic language detection for better OCR results.", comment: "")
  476. let tStrVPN = NSLocalizedString("The OCR service works via an internet connection. We would suggest you to perform OCR using a VPN connection while the service is limited.", comment: "")
  477. let plan = UserDefaults.standard.integer(forKey: "KMOCRCurrentPlanKey")
  478. if plan == 0 {
  479. textView.string = "\(tStrAuto)\n\n\(tStrVPN)"
  480. } else {
  481. textView.frame = NSRect(x: 0, y: 0, width: 300.0, height: 40.0)
  482. textView.string = tStrAuto
  483. }
  484. helpController.view = textView
  485. let popover = NSPopover()
  486. popover.delegate = self
  487. popover.contentViewController = helpController
  488. popover.animates = true
  489. popover.behavior = .transient
  490. popover.show(relativeTo: sender.bounds, of: sender as NSView, preferredEdge: .minY)
  491. }
  492. //MARK: KMImageToPDFMethodDelegate
  493. func imageToPDFMethod(_ method: KMImageToPDFMethod, progress: Float) {
  494. }
  495. }