KMBatchOperateImageToPDFViewController.swift 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  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.saveAsTestPath = self.choosePath
  239. self.method.exportPDFFile(fileArray: photoArray, savePath: path, isOCR: isOCR, isCreatPDF: isCreatNewPDF, isMerge: isMerge, isSaveAsText: isSaveAs) { [weak self] savePath, errorArr, errorOCRArray in
  240. self?.languageButton.isEnabled = true
  241. self?.planButton.isEnabled = true
  242. self?.interfaceStatus = .PrepareProcess
  243. if errorArr.count > 0 {
  244. let dict: [String: Any] = ["isMerge": false, "isSuccess": false]
  245. NotificationCenter.default.post(name: NSNotification.Name(rawValue: "KMBatchOperateImageToPDFSuccessNotification"), object: self, userInfo: dict)
  246. let alert = NSAlert()
  247. alert.messageText = NSLocalizedString("Conversion Failed", comment: "")
  248. alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
  249. alert.informativeText = "\(errorArr)"
  250. alert.alertStyle = .informational
  251. alert.runModal()
  252. } else {
  253. if errorOCRArray.count > 0 {
  254. var contextString = NSLocalizedString("Some problems occurred during the last operation:", comment: "")
  255. for filePath in errorOCRArray {
  256. contextString += "\n" + (filePath as AnyObject).lastPathComponent
  257. }
  258. let alert = NSAlert()
  259. alert.messageText = NSLocalizedString("Converted Successfully", comment: "")
  260. alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
  261. alert.informativeText = contextString
  262. alert.alertStyle = .informational
  263. let response = alert.runModal()
  264. if response == .OK {
  265. self?.viewFileAtFinder(fileName: savePath)
  266. }
  267. } else {
  268. self?.viewFileAtFinder(fileName: savePath)
  269. }
  270. }
  271. }
  272. }
  273. func viewFileAtFinder(fileName: String) {
  274. let dict = ["isMerge": true, "isSuccess": true]
  275. NotificationCenter.default.post(name: Notification.Name("KMBatchOperateImageToPDFSuccessNotification"), object: self, userInfo: dict)
  276. let workspace = NSWorkspace.shared
  277. let url = URL(fileURLWithPath: fileName)
  278. workspace.activateFileViewerSelecting([url])
  279. }
  280. //MARK: Notification
  281. @objc func OCRSelectedLanguagesChangeNotification(notification: Notification) {
  282. let selectedLanguages = notification.object/* as? [KMBatchOperateFile]*/
  283. self.updateLanguageButton(selectedLanguages as? [String])
  284. }
  285. @objc func OCRSelectedPlanChangeNotification(notification: Notification) {
  286. self.OCRSelectedPlanChangeAction()
  287. }
  288. @objc func themeChanged(notification: Notification) {
  289. DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
  290. self.updateViewColor()
  291. }
  292. }
  293. func OCRSelectedPlanChangeAction() {
  294. let plan = UserDefaults.standard.integer(forKey: "KMOCRCurrentPlanKey")
  295. if plan == 0 {
  296. self.planButton.title = " " + KMLocalizedString("Plan 1 (Online)", nil)
  297. } else {
  298. self.planButton.title = " " + KMLocalizedString("Plan 2 (Offline)", nil)
  299. }
  300. KMGOCRManager.default().selectedLanguages = NSMutableArray()
  301. self.updateLanguageButton(KMGOCRManager.default().selectedLanguages?.value(forKeyPath: KMGOCRLanguageStringKey) as? [String])
  302. }
  303. @objc func batchFilesCountNotification(notification: Notification) {
  304. let files: Array? = notification.object as? [KMBatchOperateFile]
  305. self.files? = files ?? []
  306. // if files?.count ?? 0 > 0 {
  307. // haveFiles = true
  308. // } else {
  309. // haveFiles = false
  310. // }
  311. }
  312. @IBAction func buttonClicked_CreateNewPDF(_ sender: NSButton) {
  313. if (sender.state == .on) {
  314. self.btnMerge.isEnabled = true
  315. self.appendPDFBtn.state = .off
  316. self.appendOtherPDFBtn.isEnabled = false
  317. }
  318. }
  319. @IBAction func buttonClicked_AppendOtherPDF(_ sender: NSButton) {
  320. if (sender.state == .on) {
  321. self.createNewPDFBtn.state = .off
  322. self.btnMerge.isEnabled = false
  323. self.appendOtherPDFBtn.isEnabled = true
  324. }
  325. }
  326. @IBAction func buttonClicked_OCRSelect(_ sender: NSButton) {
  327. //MARK: 判断是否付费用户
  328. if IAPProductsManager.default().isAvailableAllFunction() == false {
  329. KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
  330. self.ocrSelectBtn.state = .off
  331. return
  332. }
  333. if (sender.state == .on) {
  334. self.languageButton.isEnabled = true
  335. self.planButton.isEnabled = true
  336. self.saveAsButton.isEnabled = true
  337. } else {
  338. self.languageButton.isEnabled = false
  339. self.planButton.isEnabled = false
  340. self.saveAsButton.isEnabled = false
  341. }
  342. }
  343. @IBAction func buttonClicked_ChooseLanguage(_ sender: NSButton) {
  344. let plan = UserDefaults.standard.integer(forKey: "KMOCRCurrentPlanKey")
  345. if plan == 0 {
  346. KMGOCRManager.default().ocrType = .google
  347. } else {
  348. KMGOCRManager.default().ocrType = .apple
  349. }
  350. let popover = NSPopover()
  351. popover.delegate = self
  352. popover.contentViewController = KMLanguageViewController(nibName: "KMLanguageViewController", bundle: Bundle.main)
  353. popover.animates = true
  354. popover.behavior = .transient
  355. popover.show(relativeTo: sender.bounds, of: sender as NSView, preferredEdge: .minX)
  356. }
  357. @IBAction func buttonClicked_ChoosePlan(_ sender: NSButton) {
  358. let popover = NSPopover()
  359. popover.delegate = self
  360. popover.contentViewController = KMPlanViewController(nibName: "KMPlanViewController", bundle: Bundle.main)
  361. popover.animates = true
  362. popover.behavior = .transient
  363. popover.show(relativeTo: sender.bounds, of: sender as NSView, preferredEdge: .minX)
  364. }
  365. @IBAction func buttonClicked_ImageToPDF(_ sender: NSButton) {
  366. //MARK: 判断是否付费用户,展示iap界面
  367. if self.files?.count ?? 0 < 1 {
  368. return
  369. }
  370. if IAPProductsManager.default().isAvailableAllFunction() == false && self.files?.count ?? 0 > 1{
  371. KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
  372. return
  373. }
  374. if sender.tag == 1 {
  375. self.choosePath = ""
  376. var hasTask = false
  377. for i in 0..<(self.files?.count ?? 0) {
  378. let file = self.files?[i]
  379. file?.currentOperateInfo?.resetState()
  380. if file?.fileType == .Image {
  381. hasTask = true
  382. }
  383. }
  384. if !hasTask {
  385. NSSound.beep()
  386. return
  387. }
  388. var isOCR = false
  389. if self.ocrSelectBtn.state == .on {
  390. isOCR = true
  391. }
  392. var isSaveAs = false
  393. if self.saveAsButton.state == .on {
  394. isSaveAs = true
  395. }
  396. let plan = UserDefaults.standard.integer(forKey: "KMOCRCurrentPlanKey")
  397. if isOCR && !isConnectionAvailable() && plan == 0 {
  398. let alert = NSAlert()
  399. alert.alertStyle = .critical
  400. alert.messageText = NSLocalizedString("Connection Error", comment: "")
  401. alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
  402. alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
  403. if let window = self.view.window {
  404. alert.beginSheetModal(for: window, completionHandler: nil)
  405. } else {
  406. alert.runModal()
  407. }
  408. return
  409. }
  410. if self.createNewPDFBtn.state == .off {
  411. let appenString = self.appendTextField.stringValue
  412. if appenString.isEmpty {
  413. let alert = NSAlert()
  414. alert.alertStyle = .critical
  415. alert.messageText = NSLocalizedString("Select a File", comment: "")
  416. alert.runModal()
  417. return
  418. }
  419. }
  420. let openPanel = NSOpenPanel()
  421. openPanel.canChooseFiles = false
  422. openPanel.canChooseDirectories = true
  423. openPanel.canCreateDirectories = true
  424. openPanel.beginSheetModal(for: self.view.window!) { (result) in
  425. if result == .OK {
  426. for fileURL in openPanel.urls {
  427. self.choosePath = fileURL.path
  428. self.beginImageToPDF()
  429. }
  430. }
  431. }
  432. } else { // Do something else }
  433. }
  434. }
  435. @IBAction func buttonItemClicked_AppendOtherPDF(_ sender: NSButton) {
  436. let openPanel = NSOpenPanel()
  437. openPanel.allowedFileTypes = ["pdf"]
  438. openPanel.canChooseDirectories = false
  439. openPanel.allowsMultipleSelection = false
  440. openPanel.beginSheetModal(for: self.view.window!) { (result) in
  441. if result == .OK {
  442. guard let url = openPanel.url else { return }
  443. guard let document = PDFDocument(url: url) else {
  444. let alert = NSAlert()
  445. alert.alertStyle = .critical
  446. alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
  447. alert.runModal()
  448. return
  449. }
  450. if !document.allowsCopying || !document.allowsPrinting {
  451. let alert = NSAlert()
  452. alert.alertStyle = .critical
  453. alert.messageText = NSLocalizedString("This is a secured document. Editing is not permitted.", comment: "")
  454. alert.runModal()
  455. return
  456. }
  457. if document.isLocked {
  458. KMBaseWindowController.checkPassword(url: url, type: .owner) { [weak self] success, resultPassword in
  459. if success {
  460. self?.password = resultPassword
  461. self?.appendTextField.stringValue = url.path
  462. }
  463. }
  464. } else {
  465. self.appendTextField.stringValue = url.path
  466. }
  467. }
  468. }
  469. }
  470. @IBAction func buttonClicked_Help(_ sender: NSButton) {
  471. let helpController = NSViewController()
  472. let textView = NSTextView(frame: NSRect(x: 0, y: 0, width: 300.0, height: 100.0))
  473. textView.backgroundColor = NSColor.clear
  474. textView.isEditable = false
  475. textView.layer?.cornerRadius = 6
  476. let tStrAuto = NSLocalizedString("Choose automatic language detection for better OCR results.", comment: "")
  477. 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: "")
  478. let plan = UserDefaults.standard.integer(forKey: "KMOCRCurrentPlanKey")
  479. if plan == 0 {
  480. textView.string = "\(tStrAuto)\n\n\(tStrVPN)"
  481. } else {
  482. textView.frame = NSRect(x: 0, y: 0, width: 300.0, height: 40.0)
  483. textView.string = tStrAuto
  484. }
  485. helpController.view = textView
  486. let popover = NSPopover()
  487. popover.delegate = self
  488. popover.contentViewController = helpController
  489. popover.animates = true
  490. popover.behavior = .transient
  491. popover.show(relativeTo: sender.bounds, of: sender as NSView, preferredEdge: .minY)
  492. }
  493. //MARK: KMImageToPDFMethodDelegate
  494. func imageToPDFMethod(_ method: KMImageToPDFMethod, progress: Float) {
  495. }
  496. }