KMToolbarViewController.swift 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612
  1. //
  2. // KMToolbarViewController.swift
  3. // PDF Master
  4. //
  5. // Created by lxy on 2022/12/2.
  6. //
  7. import Cocoa
  8. @objc enum KMToolbarViewType : Int {
  9. case None
  10. case Main
  11. case Annatiton
  12. case Page
  13. case Conversion
  14. case ScanOCR
  15. case editPDF
  16. case Form
  17. case FillSign
  18. case Tool
  19. case redact
  20. case Move
  21. case Magnify
  22. case Select
  23. case SelectZoom
  24. case LeftPanel
  25. case RightPanel
  26. func isToolMode() -> Bool {
  27. return (self == .Move || self == .Magnify || self == .Select || self == .SelectZoom)
  28. }
  29. func itemIdentifier() -> String {
  30. if (self == .Annatiton) {
  31. return KMDocumentAnnotationToolbarItemIdentifier
  32. } else if (self == .Page) {
  33. return KMDocumentPageToolbarItemIdentifier
  34. } else if (self == .Conversion) {
  35. return KMDocumentConversonToolbarItemIdentifier
  36. } else if (self == .ScanOCR) {
  37. return KMDocumentScanOCRToolbarItemIdentifier
  38. } else if (self == .editPDF) {
  39. return KMDocumentEditToolbarItemIdentifier
  40. } else if (self == .Form) {
  41. return KMDocumentFormToolbarItemIdentifier
  42. } else if (self == .FillSign) {
  43. return KMDocumentFillSginToolbarItemIdentifier
  44. } else if (self == .Tool) {
  45. return KMDocumentToolToolbarItemIdentifier
  46. } else if (self == .Move) {
  47. return KMToolbarMoveToolModeItemIdentifier
  48. } else if (self == .Magnify) {
  49. return KMToolbarMagnifyToolModeItemIdentifier
  50. } else if (self == .Select) {
  51. return KMToolbarSelectToolModeItemIdentifier
  52. } else if (self == .SelectZoom) {
  53. return KMToolbarZoomToSelectionItemIdentifier
  54. } else if (self == .LeftPanel) {
  55. return KMLeftControlToolbarItemIdentifier
  56. } else if (self == .RightPanel) {
  57. return KMRightControlToolbarItemIdentifier
  58. }
  59. return ""
  60. }
  61. }
  62. @objc enum KMToolbarType: Int {
  63. /// conversion
  64. case word = 3000
  65. case excel = 3001
  66. case ppt = 3002
  67. case rtf = 3003
  68. case csv = 3004
  69. case html = 3005
  70. case conversion_text = 3006
  71. case conversion_image = 3007
  72. /// tool
  73. case compress = 8000
  74. case merge = 8001
  75. case fileCompare = 8002
  76. case secure = 8003
  77. case redact = 8004
  78. case watermark = 8005
  79. case background = 8006
  80. case headerAndFooter = 8007
  81. case bates = 8008
  82. case crop = 8009
  83. case comparison = 8010
  84. }
  85. @objc protocol KMToolbarViewControllerDelegate {
  86. @objc optional func changeAnnotationModeAction(item:KMToolbarClickButton)
  87. @objc optional func showPDFLayoutModeAction(show:Bool)
  88. @objc optional func changePDFViewZoomInAction()
  89. @objc optional func changePDFViewZoomOutAction()
  90. @objc optional func changePDFViewGotoNextPageAction()
  91. @objc optional func changePDFViewGoToPreviousPageAction()
  92. @objc optional func changePDFViewGotoBackAction()
  93. @objc optional func changePDFViewGoToForwardAction()
  94. @objc optional func aiTranslationPDFFileAction()
  95. @objc optional func toolbarViewController(_ viewController:KMToolbarViewController, zoomSting : String)
  96. @objc optional func toolbarViewController(_ viewController:KMToolbarViewController, zoomModel selectedTag:Int)
  97. @objc optional func toolbarViewController(_ viewController:KMToolbarViewController, shareAction toolbarItem: KMToolbarItemView)
  98. @objc optional func toolbarViewController(_ viewController:KMToolbarViewController, shareDocument item:NSMenuItem)
  99. @objc optional func toolbarViewController(_ viewController:KMToolbarViewController, shareFlatten item:NSMenuItem)
  100. @objc optional func toolbarViewController(_ viewController:KMToolbarViewController, shareOriginalPDF item:NSMenuItem)
  101. @objc optional func toolbarViewController(_ viewController: KMToolbarViewController, clickMode toolMode: KMToolbarViewType, toolbar toolbarItem: KMToolbarItemView, _ pages: [Int])
  102. @objc optional func toolbarViewController(_ viewController: KMToolbarViewController, clickChaildToolType: KMToolbarType, toolbar toolbarItem: KMToolbarItemView)
  103. @objc optional func toolbarViewController(_ viewController:KMToolbarViewController, scanOCRModel selectedTag:Int)
  104. @objc optional func toolbarViewController(_ viewController:KMToolbarViewController, itemDidClick toolbarItem: KMToolbarItemView)
  105. @objc optional func toolbarViewController(_ viewController:KMToolbarViewController, searchAction searchString: String)
  106. @objc optional func toolbarViewController(_ viewController:KMToolbarViewController, menuItemDidClick toolbarItem: KMToolbarItemView, index: Int, info: Any?)
  107. }
  108. class KMToolbarViewController: NSViewController, NSTextFieldDelegate {
  109. var toolbar : KMToolbarView!
  110. var toolbarType : KMToolbarViewType = KMToolbarViewType.None
  111. var toolbarItems : [String : Any] = [:]
  112. @IBOutlet weak var mainWindowController : MainWindowController!
  113. open weak var delegate: KMToolbarViewControllerDelegate?
  114. @IBOutlet var zoomButton: NSPopUpButton!
  115. @IBOutlet var zoomView: NSView!
  116. @IBOutlet weak var zoomTextField: NSTextField!
  117. var pdfView : CPDFListView = CPDFListView()
  118. var shareButton = KMToolbarClickButton()
  119. private var bottomLine = NSView()
  120. // 是否显示所有注释
  121. var isShowAllAnnotations = true
  122. var ignoreCurrentAnnotationTypeChange = false
  123. private var _currentItemView: KMToolbarItemView?
  124. override func viewDidLoad() {
  125. super.viewDidLoad()
  126. self.zoomTextField.delegate = self
  127. NotificationCenter.default.addObserver(self, selector: #selector(listViewAnnotationTypeChangeNotification), name: Notification.Name("CPDFListViewAnnotationTypeChangeNotification"), object: nil)
  128. NotificationCenter.default.addObserver(self, selector: #selector(listViewAnnotationTypeChangeNotification), name: Notification.Name("CPDFListViewToolModeChangeNotification"), object: nil)
  129. }
  130. override func loadView() {
  131. super.loadView()
  132. self.toolbar = KMToolbarView.init(identifier: "KMToolbar_New")
  133. self.toolbar.frame = self.view.bounds
  134. self.toolbar.autoresizingMask = [.width,.height]
  135. self.toolbar.delegate = self
  136. self.view.addSubview(self.toolbar)
  137. self.view.addSubview(self.bottomLine)
  138. self.bottomLine.frame = NSMakeRect(0, 0, NSWidth(self.view.bounds), 1)
  139. self.bottomLine.autoresizingMask = [.width]
  140. self.bottomLine.wantsLayer = true
  141. self.bottomLine.layer?.backgroundColor = NSColor.km_init(hex: "#0000001A").cgColor
  142. }
  143. func updateType(newType:KMToolbarViewType) {
  144. if newType != toolbarType {
  145. toolbarType = newType
  146. if self.toolbar != nil && self.toolbar.superview != nil {
  147. self.toolbar.removeFromSuperview()
  148. }
  149. self.toolbar = KMToolbarView.init(identifier: "KMToolbar_New")
  150. self.toolbar.frame = self.view.bounds
  151. self.toolbar.autoresizingMask = [.width,.height]
  152. self.toolbar.delegate = self
  153. self.view.addSubview(self.toolbar)
  154. }
  155. }
  156. func reloadateToolbar() -> Void {
  157. toolbar.reloadData()
  158. }
  159. func resetToolbar() -> Void {
  160. for item in toolbar.items {
  161. item.isSelected = false
  162. }
  163. }
  164. // MARK: Action
  165. @IBAction func changeAnnotationMode(item: KMToolbarClickButton) {
  166. self.delegate?.changeAnnotationModeAction?(item: item)
  167. }
  168. @IBAction func leftControllButtonAction(item: KMToolbarClickButton) {
  169. let tag = KMToolbarViewType(rawValue: item.tag) ?? .None
  170. if tag == .editPDF {
  171. Task { @MainActor in
  172. #if VERSION_DMG
  173. if await (KMLightMemberManager.manager.canUseAdvanced() == false) {
  174. let _ = KMComparativeTableViewController.show(window: self.view.window!)
  175. return
  176. }
  177. #endif
  178. self.delegate?.toolbarViewController?(self, clickMode: tag, toolbar: item.clickObject as! KMToolbarItemView, [])
  179. }
  180. } else {
  181. self.delegate?.toolbarViewController?(self, clickMode: tag, toolbar: item.clickObject as! KMToolbarItemView, [])
  182. }
  183. }
  184. @objc private func _itemAction(_ item: KMToolbarClickButton) {
  185. if let data = item.clickObject as? KMToolbarItemView {
  186. if data.itemIdentifier == KMToolbarComparisonItemIdentifier {
  187. self._currentItemView = data
  188. if let subMenu = data.menuFormRepresentation?.submenu {
  189. subMenu.popUp(positioning: nil, at: item.frame.origin, in: item.superview)
  190. }
  191. return
  192. }
  193. }
  194. self.delegate?.toolbarViewController?(self, itemDidClick: item.clickObject as! KMToolbarItemView)
  195. }
  196. @objc private func _comparisonAction(sender: NSMenuItem) {
  197. if let data = self._currentItemView {
  198. self.delegate?.toolbarViewController?(self, menuItemDidClick: data, index: sender.tag, info: nil)
  199. }
  200. }
  201. @IBAction func showPDFLayoutMode(sender: KMToolbarClickButton) {
  202. let item = sender.clickObject as? KMToolbarItemView
  203. if (item != nil) {
  204. item?.isSelected = !item!.isSelected
  205. }
  206. self.delegate?.showPDFLayoutModeAction?(show: true)
  207. }
  208. @objc func cropMenuAction(item: KMToolbarItemView) {
  209. self.delegate?.toolbarViewController?(self, clickChaildToolType: .crop, toolbar: item)
  210. }
  211. @objc func batesMenuAction(sender: KMToolbarClickButton) {
  212. self._currentItemView = sender.clickObject as? KMToolbarItemView
  213. if let subMenu = (sender.clickObject as? KMToolbarItemView)?.menuFormRepresentation?.submenu {
  214. subMenu.popUp(positioning: nil, at: sender.frame.origin, in: sender.superview)
  215. }
  216. }
  217. @objc private func _batesAction(sender: NSMenuItem) {
  218. if let data = self._currentItemView {
  219. self.delegate?.toolbarViewController?(self, menuItemDidClick: data, index: sender.tag, info: nil)
  220. }
  221. }
  222. @objc func headerfooterMenuAction(sender: KMToolbarClickButton) {
  223. self._currentItemView = sender.clickObject as? KMToolbarItemView
  224. if let subMenu = (sender.clickObject as? KMToolbarItemView)?.menuFormRepresentation?.submenu {
  225. subMenu.popUp(positioning: nil, at: sender.frame.origin, in: sender.superview)
  226. }
  227. }
  228. @objc private func _headerfooterAction(sender: NSMenuItem) {
  229. if let data = self._currentItemView {
  230. self.delegate?.toolbarViewController?(self, menuItemDidClick: data, index: sender.tag, info: nil)
  231. }
  232. }
  233. @objc func backgroundMenuAction(sender: KMToolbarClickButton) {
  234. self._currentItemView = sender.clickObject as? KMToolbarItemView
  235. if let subMenu = (sender.clickObject as? KMToolbarItemView)?.menuFormRepresentation?.submenu {
  236. subMenu.popUp(positioning: nil, at: sender.frame.origin, in: sender.superview)
  237. }
  238. }
  239. @objc private func _backgroundAction(sender: NSMenuItem) {
  240. if let data = self._currentItemView {
  241. self.delegate?.toolbarViewController?(self, menuItemDidClick: data, index: sender.tag, info: nil)
  242. }
  243. }
  244. @objc func watermarkMenuAction(sender: KMToolbarClickButton) {
  245. self._currentItemView = sender.clickObject as? KMToolbarItemView
  246. if let subMenu = (sender.clickObject as? KMToolbarItemView)?.menuFormRepresentation?.submenu {
  247. subMenu.popUp(positioning: nil, at: sender.frame.origin, in: sender.superview)
  248. }
  249. }
  250. @objc private func _watermarkAction(sender: NSMenuItem) {
  251. if let data = self._currentItemView {
  252. self.delegate?.toolbarViewController?(self, menuItemDidClick: data, index: sender.tag, info: nil)
  253. } else {
  254. self.delegate?.toolbarViewController?(self, menuItemDidClick: self.toolbarItemFindItemIdentifiers(value: KMToolbarToolWatermarkItemIdentifier), index: sender.tag, info: nil)
  255. }
  256. }
  257. @objc func redactMenuAction(sender: KMToolbarClickButton) {
  258. self.delegate?.toolbarViewController?(self, clickChaildToolType: .redact, toolbar: sender.clickObject as! KMToolbarItemView)
  259. }
  260. @objc func compressMenuAction(sender: KMToolbarClickButton) {
  261. self.delegate?.toolbarViewController?(self, clickChaildToolType: .compress, toolbar: sender.clickObject as! KMToolbarItemView)
  262. }
  263. @objc func secureMenuAction(sender: KMToolbarClickButton) {
  264. self.delegate?.toolbarViewController?(self, clickChaildToolType: .secure, toolbar: sender.clickObject as! KMToolbarItemView)
  265. }
  266. @objc func conversionMenuItemAction(sender: KMToolbarClickButton) {
  267. let item: KMToolbarItemView = sender.clickObject as! KMToolbarItemView
  268. var type: KMToolbarType = .word
  269. if (item.btnTag == KMToolbarType.excel.rawValue) {
  270. type = .excel
  271. } else if (item.btnTag == KMToolbarType.ppt.rawValue) {
  272. type = .ppt
  273. } else if (item.btnTag == KMToolbarType.rtf.rawValue) {
  274. type = .rtf
  275. } else if (item.btnTag == KMToolbarType.csv.rawValue) {
  276. type = .csv
  277. } else if (item.btnTag == KMToolbarType.html.rawValue) {
  278. type = .html
  279. } else if (item.btnTag == KMToolbarType.conversion_text.rawValue) {
  280. type = .conversion_text
  281. } else if (item.btnTag == KMToolbarType.conversion_image.rawValue) {
  282. type = .conversion_image
  283. }
  284. self.delegate?.toolbarViewController?(self, clickChaildToolType: type, toolbar: item)
  285. }
  286. @objc private func _pdfToImageAction(sender: NSMenuItem) {
  287. if let data = self._currentItemView {
  288. self.delegate?.toolbarViewController?(self, menuItemDidClick: data, index: sender.tag, info: nil)
  289. } else {
  290. self.delegate?.toolbarViewController?(self, menuItemDidClick: self.toolbarItemFindItemIdentifiers(value: KMToolbarConversionImageItemIdentifier), index: sender.tag, info: nil)
  291. }
  292. }
  293. @objc private func _exportImageAction(sender: NSMenuItem) {
  294. if let data = self._currentItemView {
  295. self.delegate?.toolbarViewController?(self, menuItemDidClick: data, index: sender.tag, info: nil)
  296. } else {
  297. self.delegate?.toolbarViewController?(self, menuItemDidClick: self.toolbarItemFindItemIdentifiers(value: KMToolbarConversionExportImageItemIdentifier), index: sender.tag, info: nil)
  298. }
  299. }
  300. @IBAction func zoomModelSelectButtonAction(_ sender: NSPopUpButton) {
  301. self.delegate?.toolbarViewController?(self, zoomModel: sender.selectedTag())
  302. for item in sender.itemArray {
  303. item.state = .off
  304. }
  305. sender.selectedItem?.state = .on
  306. }
  307. @IBAction func zoomPDFViewButtonAction(sender:KMToolbarClickButton) {
  308. if sender.tag == 0 {
  309. self.delegate?.changePDFViewZoomOutAction?()
  310. } else if sender.tag == 1 {
  311. self.delegate?.changePDFViewZoomInAction?()
  312. } else if sender.tag == 2 {
  313. self.delegate?.changePDFViewGotoBackAction?()
  314. } else if sender.tag == 3 {
  315. self.delegate?.changePDFViewGoToForwardAction?()
  316. }
  317. }
  318. @IBAction func aiTranslationButtonAction(sender:KMToolbarClickButton) {
  319. self.delegate?.aiTranslationPDFFileAction?()
  320. }
  321. @IBAction func shareButtonAction(sender:KMToolbarClickButton) {
  322. self.shareButton = sender
  323. let menu = NSMenu()
  324. menu.addItem(withTitle: NSLocalizedString("Document", comment: ""), action: #selector(shareViaWithDocument), target: self)
  325. menu.addItem(withTitle: NSLocalizedString("Flattened Copy", comment: ""), action: #selector(shareViaWithFlatten), target: self)
  326. menu.addItem(withTitle: NSLocalizedString("Original PDF", comment: ""), action: #selector(shareViaWithOriginalPDF), target: self)
  327. menu.popUp(positioning: nil, at: NSPoint(x: sender.frame.origin.x, y: sender.frame.origin.y-10), in: sender.superview)
  328. self.delegate?.toolbarViewController?(self, shareAction: sender.clickObject as! KMToolbarItemView)
  329. }
  330. @IBAction func shareViaWithDocument(sender:NSMenuItem) {
  331. self.delegate?.toolbarViewController?(self, shareDocument: sender)
  332. }
  333. @IBAction func shareViaWithFlatten(sender:NSMenuItem) {
  334. self.delegate?.toolbarViewController?(self, shareFlatten: sender)
  335. }
  336. @IBAction func shareViaWithOriginalPDF(sender:NSMenuItem) {
  337. self.delegate?.toolbarViewController?(self, shareOriginalPDF: sender)
  338. }
  339. @objc func mergeMenuItemAction(sender: KMToolbarClickButton) {
  340. self.delegate?.toolbarViewController?(self, clickChaildToolType: .merge, toolbar: sender.clickObject as! KMToolbarItemView)
  341. }
  342. @IBAction func scanOCRModelSelect(sender:KMToolbarClickButton) {
  343. self.delegate?.toolbarViewController?(self, scanOCRModel: sender.tag)
  344. }
  345. // Form 对齐
  346. @IBAction func formsAlignmentAction(sender:KMToolbarClickButton) {
  347. }
  348. @objc private func _alignmentAction(sender: NSMenuItem) {
  349. if let data = self._currentItemView {
  350. self.delegate?.toolbarViewController?(self, menuItemDidClick: data, index: sender.tag, info: nil)
  351. } else {
  352. self.delegate?.toolbarViewController?(self, menuItemDidClick: self.toolbarItemFindItemIdentifiers(value: KMToolbarToolFormAlignIdentifier), index: sender.tag, info: nil)
  353. }
  354. }
  355. // Form 更多操作
  356. @IBAction func formsMoreOperationAction(sender:KMToolbarClickButton) {
  357. }
  358. func toolbarItemFindItemIdentifiers(value : String) -> KMToolbarItemView{
  359. for item in self.toolbarItems {
  360. if item.key == value {
  361. return item.value as! KMToolbarItemView
  362. }
  363. }
  364. return KMToolbarItemView()
  365. }
  366. func controlTextDidEndEditing(_ obj: Notification) {
  367. let textField = obj.object as? NSTextField
  368. if textField == self.zoomTextField {
  369. self.delegate?.toolbarViewController?(self, zoomSting: self.zoomTextField.stringValue)
  370. }
  371. }
  372. func controlTextDidChange(_ obj: Notification) {
  373. }
  374. func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
  375. switch commandSelector {
  376. case #selector(NSResponder.insertNewline(_:)):
  377. if let inputView = control as? NSTextField {
  378. // //当当前TextField按下enter
  379. if inputView == zoomTextField {
  380. KMPrint("按下 enter")
  381. self.delegate?.toolbarViewController?(self, zoomSting: self.zoomTextField.stringValue)
  382. } else if let _ = control as? NSSearchField {
  383. self.delegate?.toolbarViewController?(self, searchAction: control.stringValue)
  384. }
  385. }
  386. return true
  387. default:
  388. return false
  389. }
  390. }
  391. }
  392. // MARK: - Public Methods
  393. extension KMToolbarViewController {
  394. func itemAction(_ item: KMToolbarItemView) {
  395. self._itemAction(item.clickButton)
  396. }
  397. }
  398. extension KMToolbarViewController : KMToolbarViewDelegate,NSToolbarItemValidation {
  399. func toolbarLeftDefaultItemIdentifiers(_ toolbar: KMToolbarView) -> [String] {
  400. if toolbarType == .Main {
  401. return [KMLeftControlToolbarItemIdentifier,
  402. KMDocumentZoomViewToolbarItemIdentifier, KMDocumentZoomOutToolbarItemIdentifier, KMDocumentZoomToolbarItemIdentifier,
  403. KMDocumentPreviousPageToolbarItemIdentifier, KMDocumentNextPageToolbarItemIdentifier, KMDocumentHomeToolbarItemIdentifier]
  404. }
  405. return []
  406. }
  407. func toolbarRightDefaultItemIdentifiers(_ toolbar: KMToolbarView) -> [String] {
  408. if toolbarType == .Main {
  409. return [KMDocumentViewSettingToolbarItemIdentifier, KMDocumentShareToolbarItemIdentifier,
  410. KMDocumentSearchToolbarItemIdentifier, KMRightControlToolbarItemIdentifier]
  411. } else if [.Annatiton,.Magnify,.Move,.Select,.SelectZoom].contains(toolbarType) {
  412. return [KMToolbarAnnotationSettingItemIdentifier]
  413. }
  414. return []
  415. }
  416. func toolbarAllowedItemIdentifiers(_ toolbar: KMToolbarView) -> [String] {
  417. if [.Annatiton,.Magnify,.Move,.Select,.SelectZoom].contains(toolbarType) {
  418. return [KMNewToolbarSpaceItemIdentifier,
  419. KMToolbarPageEditInsetItemIdentifier, KMToolbarToolMergeItemIdentifier, KMToolbarPageEditSplitItemIdentifier,
  420. KMToolbarToolCompressItemIdentifier, KMToolbarToolSecureItemIdentifier, KMToolbarToolWatermarkItemIdentifier,
  421. KMToolbarToolBackgroundItemIdentifier, KMToolbarToolHeaderFooterItemIdentifier, KMToolbarToolBatesItemIdentifier,
  422. KMToolbarToolCropItemIdentifier,
  423. KMToolbarConversionWordItemIdentifier, KMToolbarConversionExcelItemIdentifier, KMToolbarConversionPPTItemIdentifier,
  424. KMToolbarConversionRTFItemIdentifier, KMToolbarConversionCSVItemIdentifier, KMToolbarConversionHTMLItemIdentifier,
  425. KMToolbarConversionTextItemIdentifier, KMToolbarConversionImageItemIdentifier,
  426. KMToolbarMoveToolModeItemIdentifier,
  427. KMToolbarMagnifyToolModeItemIdentifier,
  428. KMToolbarSelectToolModeItemIdentifier,
  429. KMToolbarZoomToSelectionItemIdentifier,
  430. KMNewToolbarSpaceItemIdentifier,
  431. KMToolbarDividerItemIdentifier,
  432. KMNewToolbarSpaceItemIdentifier,
  433. KMToolbarHighlightAnnotationItemIdentifier,
  434. KMToolbarUnderlineAnnotationItemIdentifier,
  435. KMToolbarStrikeOutAnnotationItemIdentifier,
  436. KMToolbarInkAnnotationItemIdentifier,
  437. KMToolbarFreeTextAnnotationItemIdentifier,
  438. KMToolbarAnchoredAnnotationItemIdentifier,
  439. KMToolbarSquareAnnotationItemIdentifier, KMToolbarCircleAnnotationItemIdentifier, KMToolbarArrowAnnotationItemIdentifier, KMToolbarLineAnnotationItemIdentifier,
  440. KMToolbarLinkAnnotationItemIdentifier,
  441. KMAnnotationStampToolbarItemIdentifier,
  442. KMToolbarSignSignatureAnnotationItemIdentifier,
  443. KMToolbarDividerItemIdentifier,
  444. KMToolbarShowToolbarItemIdentifier,
  445. KMToolbarToolRadioButtonItemIdentifier]
  446. }
  447. return []
  448. }
  449. func toolbarDefaultItemIdentifiers(_ toolbar: KMToolbarView) -> [String] {
  450. switch toolbarType {
  451. case .None:
  452. return []
  453. case .Main:
  454. return [KMDocumentAnnotationToolbarItemIdentifier,
  455. KMDocumentPageToolbarItemIdentifier,
  456. KMDocumentToolToolbarItemIdentifier,
  457. KMDocumentConversonToolbarItemIdentifier,
  458. KMDocumentFormToolbarItemIdentifier,
  459. KMDocumentFillSginToolbarItemIdentifier,
  460. KMDocumentEditToolbarItemIdentifier,
  461. KMDocumentRedactToolbarItemIdentifier,
  462. KMDocumentScanOCRToolbarItemIdentifier]
  463. case .Annatiton,.Magnify,.Move,.Select,.SelectZoom:
  464. let itemIdentifiers: [String]? = self.toolbar?.toolbarIdentifier != nil ? (UserDefaults.standard.object(forKey: self.toolbar!.toolbarIdentifier!) as? [String]) : []
  465. if itemIdentifiers == nil || itemIdentifiers!.count <= 0 {
  466. return [KMToolbarMoveToolModeItemIdentifier,
  467. KMToolbarMagnifyToolModeItemIdentifier,
  468. KMToolbarSelectToolModeItemIdentifier,
  469. KMToolbarZoomToSelectionItemIdentifier,
  470. KMNewToolbarSpaceItemIdentifier,
  471. KMToolbarDividerItemIdentifier,
  472. KMNewToolbarSpaceItemIdentifier,
  473. KMToolbarHighlightAnnotationItemIdentifier,
  474. KMToolbarUnderlineAnnotationItemIdentifier,
  475. KMToolbarStrikeOutAnnotationItemIdentifier,
  476. KMToolbarInkAnnotationItemIdentifier,
  477. KMToolbarFreeTextAnnotationItemIdentifier,
  478. KMToolbarAnchoredAnnotationItemIdentifier,
  479. KMToolbarSquareAnnotationItemIdentifier, KMToolbarCircleAnnotationItemIdentifier, KMToolbarArrowAnnotationItemIdentifier, KMToolbarLineAnnotationItemIdentifier,
  480. KMToolbarLinkAnnotationItemIdentifier,
  481. KMAnnotationStampToolbarItemIdentifier,
  482. KMToolbarSignSignatureAnnotationItemIdentifier,
  483. KMToolbarDividerItemIdentifier,
  484. KMToolbarShowToolbarItemIdentifier]
  485. }
  486. return itemIdentifiers!
  487. case .editPDF:
  488. return [KMToolbarAddTextEditPDFItemIdentifier,
  489. KMToolbarAddImageEditPDFItemIdentifier]
  490. case .Page:
  491. return []
  492. case .Tool:
  493. return [KMToolbarToolCompressItemIdentifier, KMToolbarToolMergeItemIdentifier,
  494. KMToolbarToolSecureItemIdentifier, KMToolbarComparisonItemIdentifier,
  495. KMToolbarToolWatermarkItemIdentifier, KMToolbarToolBackgroundItemIdentifier,
  496. KMToolbarToolHeaderFooterItemIdentifier, KMToolbarToolBatesItemIdentifier]
  497. case .Form:
  498. return [KMToolbarToolTextFieldItemIdentifier,
  499. KMToolbarToolCheckBoxItemIdentifier,
  500. KMToolbarToolRadioButtonItemIdentifier,
  501. KMToolbarToolListBoxItemIdentifier,
  502. KMToolbarToolPullDownmenuItemIdentifier,
  503. KMToolbarToolButtonIdentifier,
  504. KMToolbarToolSignBoxIdentifier,
  505. KMToolbarDividerItemIdentifier,
  506. KMToolbarToolFormAlignIdentifier,
  507. KMToolbarToolFormMoreIdentifier]
  508. case .FillSign:
  509. return [KMToolbarToolTextIdentifier,
  510. KMToolbarToolHookItemIdentifier,
  511. KMToolbarToolForkItemIdentifier,
  512. KMToolbarToolRectangleIdentifier,
  513. KMToolbarToolLineItemIdentifier,
  514. KMToolbarToolDotItemIdentifier,
  515. KMToolbarToolDateIdentifier,
  516. KMToolbarToolProfileIdentifier,
  517. KMToolbarFillSignSignatureIdentifier]
  518. case .Conversion:
  519. return [KMToolbarConversionWordItemIdentifier,
  520. KMToolbarConversionExcelItemIdentifier,
  521. KMToolbarConversionPPTItemIdentifier,
  522. KMToolbarConversionRTFItemIdentifier,
  523. KMToolbarConversionCSVItemIdentifier,
  524. KMToolbarConversionHTMLItemIdentifier,
  525. KMToolbarConversionTextItemIdentifier,
  526. KMToolbarConversionImageItemIdentifier,
  527. KMDocumentScanOCRToolbarItemIdentifier, KMToolbarConversionExportImageItemIdentifier]
  528. case .ScanOCR:
  529. return [KMToolbarToolEnhancedScanIdentifier,
  530. KMToolbarToolOCRTextIdentifier]
  531. default:
  532. break
  533. }
  534. return []
  535. }
  536. func toolbar(_ toolbar: KMToolbarView, itemFor identifier: String) -> KMToolbarItemView {
  537. var item: KMToolbarItemView? = self.toolbarItems[identifier] as? KMToolbarItemView
  538. var create = true
  539. if let data = item {
  540. let pId = parentIdentifier(data.itemIdentifier ?? "")
  541. if [.Annatiton,.Magnify,.Move,.Select,.SelectZoom].contains(toolbarType) && (pId != KMDocumentAnnotationToolbarItemIdentifier || data.itemIdentifier! == KMToolbarAnnotationSettingItemIdentifier) {
  542. create = true
  543. }
  544. }
  545. if item == nil || create {
  546. item = KMToolbarItemView.init(itemIdentifier: identifier)
  547. self.toolbarItems[identifier] = item
  548. if isMainToolItem(identifier) {
  549. self._setupMainItem(item)
  550. } else {
  551. if (annotationToolIdentifiers.contains(identifier)) {
  552. self._setupAnnotationItem(item)
  553. } else if editPDFItemIdentifiers.contains(identifier) {
  554. self._setupEditItem(item)
  555. } else if conversionToolIdentifiers.contains(identifier) {
  556. self._setupConvertItem(item)
  557. } else if fillSignToolIdentifiers.contains(identifier) {
  558. self._setupFillSignItem(item)
  559. } else if formToolIdentifiers.contains(identifier) {
  560. self._setupFormItem(item)
  561. } else if toolToolIdentifiers.contains(identifier) {
  562. self._setupToolItem(item)
  563. }
  564. }
  565. }
  566. return item!
  567. }
  568. func validateToolbarItem(_ item: NSToolbarItem) -> Bool {
  569. return true
  570. }
  571. @objc func listViewAnnotationTypeChangeNotification(sender: Notification?) {
  572. // if let notiName = sender?.name, notiName == NSNotification.Name.CPDFListViewAnnotationTypeChange, self.ignoreCurrentAnnotationTypeChange {
  573. // }
  574. if (self.ignoreCurrentAnnotationTypeChange) {
  575. // 忽略后重置 这个属性是基于单次添加,所以使用后会重置
  576. // self.ignoreCurrentAnnotationTypeChange = false
  577. return
  578. }
  579. let annotationType : CAnnotationType = pdfView.annotationType
  580. if annotationType == .square || annotationType == .circle || annotationType == .arrow || annotationType == .line{
  581. UserDefaults.standard.set(pdfView.annotationType.rawValue, forKey: KMToolBarToolPDFShapeStyle)
  582. UserDefaults.standard.synchronize()
  583. }
  584. for item in self.toolbar.items {
  585. if self.toolbarType == .Annatiton || self.toolbarType == .Move || self.toolbarType == .Magnify ||
  586. self.toolbarType == .Select || self.toolbarType == .SelectZoom {
  587. item.isSelected = false
  588. if item.itemIdentifier == KMDocumentAnnotationToolbarItemIdentifier {
  589. item.isSelected = true
  590. } else if item.itemIdentifier == KMToolbarHighlightAnnotationItemIdentifier {
  591. if annotationType == .highlight {
  592. item.isSelected = true
  593. }
  594. } else if item.itemIdentifier == KMToolbarUnderlineAnnotationItemIdentifier {
  595. if annotationType == .underline {
  596. item.isSelected = true
  597. }
  598. } else if item.itemIdentifier == KMToolbarStrikeOutAnnotationItemIdentifier {
  599. if annotationType == .strikeOut {
  600. item.isSelected = true
  601. }
  602. } else if item.itemIdentifier == KMToolbarInkAnnotationItemIdentifier {
  603. if annotationType == .ink || annotationType == .eraser {
  604. item.isSelected = true
  605. }
  606. } else if item.itemIdentifier == KMToolbarFreeTextAnnotationItemIdentifier {
  607. if annotationType == .freeText {
  608. item.isSelected = true
  609. }
  610. } else if item.itemIdentifier == KMToolbarAnchoredAnnotationItemIdentifier {
  611. if annotationType == .anchored {
  612. item.isSelected = true
  613. }
  614. } else if item.itemIdentifier == KMToolbarSquareAnnotationItemIdentifier {
  615. if annotationType == .square {
  616. item.isSelected = true
  617. }
  618. } else if item.itemIdentifier == KMToolbarCircleAnnotationItemIdentifier {
  619. if annotationType == .circle {
  620. item.isSelected = true
  621. }
  622. } else if item.itemIdentifier == KMToolbarArrowAnnotationItemIdentifier {
  623. if annotationType == .arrow {
  624. item.isSelected = true
  625. }
  626. } else if item.itemIdentifier == KMToolbarLineAnnotationItemIdentifier {
  627. if annotationType == .line {
  628. item.isSelected = true
  629. }
  630. } else if item.itemIdentifier == KMToolbarLinkAnnotationItemIdentifier {
  631. if annotationType == .link {
  632. item.isSelected = true
  633. }
  634. } else if item.itemIdentifier == KMAnnotationStampToolbarItemIdentifier {
  635. if annotationType == .stamp {
  636. item.isSelected = true
  637. }
  638. } else if item.itemIdentifier == KMToolbarSignSignatureAnnotationItemIdentifier {
  639. if annotationType == .signSignature {
  640. item.isSelected = true
  641. }
  642. } else if pdfView.toolMode == .moveToolMode {
  643. if item.itemIdentifier == KMToolbarMoveToolModeItemIdentifier {
  644. item.isSelected = true
  645. }
  646. } else if pdfView.toolMode == .magnifyToolMode {
  647. if item.itemIdentifier == KMToolbarMagnifyToolModeItemIdentifier {
  648. item.isSelected = true
  649. }
  650. } else if pdfView.toolMode == .selectToolMode {
  651. if item.itemIdentifier == KMToolbarSelectToolModeItemIdentifier {
  652. item.isSelected = true
  653. }
  654. } else if pdfView.toolMode == .selectZoomToolMode {
  655. if item.itemIdentifier == KMToolbarZoomToSelectionItemIdentifier {
  656. item.isSelected = true
  657. }
  658. }
  659. if (item.itemIdentifier == KMToolbarShowToolbarItemIdentifier) {
  660. item.isSelected = !self.isShowAllAnnotations
  661. }
  662. } else if self.toolbarType == .FillSign {
  663. item.isSelected = false
  664. if pdfView.toolMode == .selfSignMode {
  665. if item.itemIdentifier == KMToolbarToolHookItemIdentifier {
  666. if annotationType == .signTure {
  667. item.isSelected = true
  668. }
  669. } else if item.itemIdentifier == KMToolbarToolForkItemIdentifier {
  670. if annotationType == .signFalse {
  671. item.isSelected = true
  672. }
  673. } else if item.itemIdentifier == KMToolbarToolLineItemIdentifier {
  674. if annotationType == .signLine {
  675. item.isSelected = true
  676. }
  677. } else if item.itemIdentifier == KMToolbarToolDotItemIdentifier {
  678. if annotationType == .signDot {
  679. item.isSelected = true
  680. }
  681. } else if item.itemIdentifier == KMToolbarToolRectangleIdentifier {
  682. if annotationType == .signCircle {
  683. item.isSelected = true
  684. }
  685. } else if item.itemIdentifier == KMToolbarToolDateIdentifier {
  686. if annotationType == .signDate {
  687. item.isSelected = true
  688. }
  689. } else if item.itemIdentifier == KMToolbarToolTextIdentifier {
  690. if annotationType == .signText {
  691. item.isSelected = true
  692. }
  693. } else if (item.itemIdentifier == KMToolbarFillSignSignatureIdentifier) {
  694. if (annotationType == .signSignature) {
  695. item.isSelected = true
  696. }
  697. }
  698. }
  699. }
  700. }
  701. }
  702. }
  703. extension KMToolbarViewController: NSSearchFieldDelegate {
  704. }
  705. extension KMToolbarViewController {
  706. private func _setupMainItem(_ item: KMToolbarItemView?) {
  707. let identifier = item?.itemIdentifier
  708. if identifier == KMLeftControlToolbarItemIdentifier {
  709. item?.image = NSImage(named: "KMImageNameUXIconBtnTriLeftNor")
  710. item?.titleName = NSLocalizedString("Panel", comment: "")
  711. item?.target = self
  712. item?.toolTip = NSLocalizedString("View Settings", comment: "")
  713. item?.boxImagePosition = .imageAbove
  714. item?.btnAction = #selector(_itemAction)
  715. } else if identifier == KMDocumentZoomToolbarItemIdentifier {
  716. item?.image = NSImage(named: "KMImageNameUXIconToolbarZoominNor")
  717. item?.titleName = NSLocalizedString("", comment: "")
  718. item?.target = self
  719. item?.btnTag = 1
  720. item?.toolTip = NSLocalizedString("Zoom In", comment: "")
  721. item?.boxImagePosition = .imageAbove
  722. item?.btnAction = #selector(zoomPDFViewButtonAction)
  723. } else if identifier == KMDocumentZoomOutToolbarItemIdentifier {
  724. item?.image = NSImage(named: "KMImageNameUXIconToolbarZoomoutNor")
  725. item?.titleName = NSLocalizedString("", comment: "")
  726. item?.target = self
  727. item?.btnTag = 0
  728. item?.toolTip = NSLocalizedString("Zoom Out", comment: "")
  729. item?.boxImagePosition = .imageAbove
  730. item?.btnAction = #selector(zoomPDFViewButtonAction)
  731. } else if identifier == KMDocumentZoomViewToolbarItemIdentifier{
  732. item?.titleName = NSLocalizedString("Zoom", comment: "")
  733. item?.target = self
  734. let view = NSView()
  735. view.frame = NSMakeRect(0, 0, 70, 40)
  736. let boxView = NSView()
  737. boxView.frame = NSMakeRect(0, 16, 70, 22)
  738. view.addSubview(boxView)
  739. boxView.addSubview(self.zoomView)
  740. self.zoomView.frame = NSMakeRect(10, 3, NSWidth(self.zoomView.frame), NSHeight(self.zoomView.frame))
  741. let titleLabel = NSTextField(labelWithString: NSLocalizedString("Zoom", comment: ""))
  742. view.addSubview(titleLabel)
  743. titleLabel.frame = NSMakeRect(0, 0, 70, 16)
  744. titleLabel.alignment = .right
  745. boxView.wantsLayer = true
  746. boxView.layer?.borderWidth = 1
  747. boxView.layer?.borderColor = NSColor.lightGray.cgColor
  748. item?.customizeView = view
  749. } else if identifier == KMDocumentNextPageToolbarItemIdentifier {
  750. item?.image = NSImage(named: "KMImageNameToolbarPagenextNor")
  751. item?.titleName = NSLocalizedString("Next", comment: "")
  752. item?.target = self
  753. item?.toolTip = NSLocalizedString("Go To Next Page", comment: "")
  754. item?.boxImagePosition = .imageAbove
  755. item?.btnAction = #selector(_itemAction)
  756. } else if identifier == KMDocumentPreviousPageToolbarItemIdentifier {
  757. item?.image = NSImage(named: "KMImageNameToolbarPagepreviousNor")
  758. item?.titleName = NSLocalizedString("Previous", comment: "")
  759. item?.target = self
  760. item?.toolTip = NSLocalizedString("Go To Previous Page", comment: "")
  761. item?.boxImagePosition = .imageAbove
  762. item?.btnAction = #selector(_itemAction)
  763. } else if identifier == KMDocumentHomeToolbarItemIdentifier {
  764. item?.image = NSImage(named: "KMImageNameToolbarHomeNor")
  765. item?.titleName = NSLocalizedString("Home", comment: "")
  766. item?.target = self
  767. item?.toolTip = NSLocalizedString("A Welcome Gift from Us", comment: "")
  768. item?.boxImagePosition = .imageAbove
  769. item?.btnAction = #selector(_itemAction)
  770. } else if identifier == KMDocumentAnnotationToolbarItemIdentifier {
  771. item?.titleName = NSLocalizedString("Tools", comment: "")
  772. item?.image = NSImage(named: "KMImageNameUXIconToolbarMytoolsNor")
  773. item?.target = self
  774. item?.toolTip = String(format: "%@: %@, %@, %@, %@", KMLocalizedString("Tool Mode", nil),KMLocalizedString("Annotate", nil),KMLocalizedString("Scroll", nil),KMLocalizedString("Magnify", nil),KMLocalizedString("Select", nil))
  775. item?.btnTag = KMToolbarViewType.Annatiton.rawValue
  776. item?.btnAction = #selector(leftControllButtonAction)
  777. item?.boxImagePosition = .imageAbove
  778. } else if identifier == KMDocumentPageToolbarItemIdentifier {
  779. item?.titleName = NSLocalizedString("Page Edit", comment: "")
  780. item?.target = self
  781. item?.image = NSImage(named: "KMImageNameUXIconToolbarPageeditNor")
  782. item?.toolTip = NSLocalizedString("PDF page editor: insert, delete, extract, rotate, reposition, and replace pages in a PDF", comment: "")
  783. item?.btnTag = KMToolbarViewType.Page.rawValue
  784. item?.btnAction = #selector(leftControllButtonAction)
  785. item?.boxImagePosition = .imageAbove
  786. } else if identifier == KMDocumentConversonToolbarItemIdentifier {
  787. item?.titleName = NSLocalizedString("Converter", comment: "")
  788. item?.target = self
  789. item?.image = NSImage(named: "KMImageNameUXIconToolbarConvertNor")
  790. item?.toolTip = NSLocalizedString("Convert PDFs to Microsoft Word, PowerPoint, Excel, RTF, Text, Image, CSV, and more Offline", comment: "")
  791. item?.btnTag = KMToolbarViewType.Conversion.rawValue
  792. item?.btnAction = #selector(leftControllButtonAction)
  793. item?.boxImagePosition = .imageAbove
  794. } else if identifier == KMDocumentScanOCRToolbarItemIdentifier {
  795. item?.titleName = NSLocalizedString("OCR", comment: "")
  796. item?.target = self
  797. item?.image = NSImage(named: "KMImageNameToolbarOCRNor")
  798. item?.boxImagePosition = .imageAbove
  799. item?.toolTip = NSLocalizedString("Recognize text from Image-based or Scanned PDF with OCR", comment: "")
  800. item?.btnAction = #selector(_itemAction)
  801. } else if identifier == KMToolbarToolEnhancedScanIdentifier {
  802. item?.image = NSImage(named: "KMImageNameMainToolEnhancedScan")
  803. item?.target = self
  804. item?.btnTag = 0
  805. item?.toolTip = NSLocalizedString("Enhanced Scan", comment: "")
  806. item?.titleName = NSLocalizedString("Enhanced Scan", comment: "")
  807. item?.boxImagePosition = .imageLeft
  808. item?.btnAction = #selector(scanOCRModelSelect)
  809. } else if identifier == KMToolbarToolOCRTextIdentifier {
  810. item?.image = NSImage(named: "KMImageNameMainToolOCRText")
  811. item?.target = self
  812. item?.toolTip = NSLocalizedString("OCR Text Recognition", comment: "")
  813. item?.titleName = NSLocalizedString("OCR Text Recognition", comment: "")
  814. item?.boxImagePosition = .imageLeft
  815. item?.btnAction = #selector(scanOCRModelSelect)
  816. } else if identifier == KMDocumentEditToolbarItemIdentifier {
  817. item?.titleName = NSLocalizedString("Edit PDF", comment: "")
  818. item?.target = self
  819. item?.image = NSImage(named: "KMImageNameUXIconToolbarEditNor")
  820. item?.boxImagePosition = .imageAbove
  821. item?.btnTag = KMToolbarViewType.editPDF.rawValue
  822. item?.toolTip = NSLocalizedString("Edit text and image in PDF", comment: "")
  823. item?.btnAction = #selector(leftControllButtonAction)
  824. } else if identifier == KMDocumentFormToolbarItemIdentifier {
  825. item?.titleName = NSLocalizedString("Forms", comment: "")
  826. item?.target = self
  827. item?.image = NSImage(named: "KMImageNameUXIconToolbarFormNor")
  828. item?.boxImagePosition = .imageAbove
  829. item?.btnTag = KMToolbarViewType.Form.rawValue
  830. item?.toolTip = NSLocalizedString("Edit PDF Form", comment: "")
  831. item?.btnAction = #selector(leftControllButtonAction)
  832. } else if identifier == KMDocumentFillSginToolbarItemIdentifier {
  833. item?.titleName = NSLocalizedString("Fill & Sign", comment: "")
  834. item?.target = self
  835. item?.image = NSImage(named: "KMImageNameUXIconToolbarFillsignNor")
  836. item?.boxImagePosition = .imageAbove
  837. item?.btnTag = KMToolbarViewType.FillSign.rawValue
  838. item?.toolTip = NSLocalizedString("Fill and sign forms", comment: "")
  839. item?.btnAction = #selector(leftControllButtonAction)
  840. } else if identifier == KMDocumentToolToolbarItemIdentifier {
  841. item?.titleName = NSLocalizedString("Editor", comment: "")
  842. item?.target = self
  843. item?.image = NSImage(named: "KMImageNameUXIconToolbarEdittoolNor")
  844. item?.boxImagePosition = .imageAbove
  845. item?.btnTag = KMToolbarViewType.Tool.rawValue
  846. item?.toolTip = NSLocalizedString("Edit, delete, cut, copy, paste, and insert text in PDFs", comment: "")
  847. item?.btnAction = #selector(leftControllButtonAction)
  848. } else if identifier == KMDocumentRedactToolbarItemIdentifier {
  849. item?.titleName = NSLocalizedString("Redact Text", comment: "")
  850. item?.target = self
  851. item?.image = NSImage(named: "KMImageNameUXIconToolbarRedactNor")
  852. item?.boxImagePosition = .imageAbove
  853. item?.toolTip = NSLocalizedString("Mark for redaction", comment: "")
  854. item?.btnAction = #selector(_itemAction)
  855. } else if identifier == KMDocumentAITranslationToolbarItemIdentifier {
  856. item?.image = NSImage(named: "ic_function_other_AITranslation")
  857. item?.titleName = "AI Translation"
  858. item?.target = self
  859. item?.toolTip = NSLocalizedString("AI Translation", comment: "")
  860. item?.boxImagePosition = .imageOnly
  861. item?.btnAction = #selector(aiTranslationButtonAction)
  862. } else if identifier == KMDocumentPrintToolbarItemIdentifier {
  863. item?.image = NSImage(named: "KMImageNameMainToolbarPrint")
  864. item?.titleName = "Print"
  865. item?.target = self
  866. item?.toolTip = NSLocalizedString("Print", comment: "")
  867. item?.boxImagePosition = .imageOnly
  868. item?.btnAction = #selector(_itemAction)
  869. } else if identifier == KMDocumentViewSettingToolbarItemIdentifier {
  870. item?.image = NSImage(named: "KMImageNameUXIconToolbarPageviewNor")
  871. item?.titleName = NSLocalizedString("Page Display", comment: "")
  872. item?.target = self
  873. item?.toolTip = NSLocalizedString("Page Display", comment: "")
  874. item?.boxImagePosition = .imageAbove
  875. item?.btnAction = #selector(_itemAction)
  876. } else if identifier == KMDocumentShareToolbarItemIdentifier {
  877. item?.image = NSImage(named: "KMImageNameUXIconToolbarShareNor")
  878. item?.titleName = NSLocalizedString("Share", comment: "")
  879. item?.target = self
  880. item?.toolTip = NSLocalizedString("Share the file with others", comment: "")
  881. item?.boxImagePosition = .imageAbove
  882. item?.btnAction = #selector(shareButtonAction)
  883. let menuItem = NSMenuItem.init(title: item!.titleName ?? "", action: nil, target: self)
  884. let menu = NSMenu()
  885. menu.addItem(withTitle: NSLocalizedString("Document", comment: ""), action: #selector(shareViaWithDocument), target: self)
  886. menu.addItem(withTitle: NSLocalizedString("Flattened Copy", comment: ""), action: #selector(shareViaWithFlatten), target: self)
  887. menu.addItem(withTitle: NSLocalizedString("Original PDF", comment: ""), action: #selector(shareViaWithOriginalPDF), target: self)
  888. menuItem.submenu = menu
  889. item?.menuFormRepresentation = menuItem
  890. } else if identifier == KMDocumentSearchToolbarItemIdentifier {
  891. item?.titleName = NSLocalizedString("Search", comment: "")
  892. item?.target = self
  893. let view = NSView()
  894. view.frame = NSMakeRect(0, 0, 150, 40)
  895. let boxView = NSView()
  896. boxView.frame = NSMakeRect(0, 16, 150, 22)
  897. view.addSubview(boxView)
  898. let searchView = NSSearchField()
  899. searchView.frame = NSMakeRect(0, 0, 150, 22)
  900. searchView.placeholderString = NSLocalizedString("Search", comment: "")
  901. searchView.sendsWholeSearchString = true
  902. searchView.sendsSearchStringImmediately = true
  903. searchView.drawsBackground = false
  904. searchView.delegate = self
  905. boxView.addSubview(searchView)
  906. let titleLabel = NSTextField(labelWithString: NSLocalizedString("Search", comment: ""))
  907. view.addSubview(titleLabel)
  908. titleLabel.frame = NSMakeRect(0, 0, 130, 16)
  909. titleLabel.alignment = .center
  910. item?.customizeView = view
  911. } else if identifier == KMRightControlToolbarItemIdentifier {
  912. item?.image = NSImage(named: "KMImageNameUXIconBtnTriRightNor")
  913. item?.titleName = NSLocalizedString("Properties", comment: "")
  914. item?.target = self
  915. item?.toolTip = NSLocalizedString("Show/Hide Annotation Properties Panel", comment: "")
  916. item?.boxImagePosition = .imageOnly
  917. item?.btnAction = #selector(_itemAction)
  918. } else if identifier == KMToolbarToolRedactItemIdentifier {
  919. item?.image = NSImage(named: "KMImageNameMainToolsRedact")
  920. item?.target = self
  921. item?.btnTag = KMToolbarType.redact.rawValue
  922. item?.toolTip = NSLocalizedString("Redact", comment: "")
  923. item?.titleName = NSLocalizedString("Redact", comment: "")
  924. item?.btnAction = #selector(redactMenuAction)
  925. let menuItem = NSMenuItem.init(title: "Redact", action: #selector(changeAnnotationMode), target: self)
  926. menuItem.tag = item!.btnTag
  927. item?.menuFormRepresentation = menuItem
  928. }
  929. }
  930. private func _setupAnnotationItem(_ item: KMToolbarItemView?) {
  931. let identifier = item?.itemIdentifier
  932. if identifier == KMToolbarMoveToolModeItemIdentifier {
  933. item?.titleName = NSLocalizedString("Scroll Tool", comment: "")
  934. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsPantool)
  935. item?.target = self
  936. item?.btnTag = KMToolbarViewType.Move.rawValue
  937. item?.toolTip = NSLocalizedString("Scroll Tool", comment: "")
  938. item?.boxImagePosition = .imageOnly
  939. item?.btnAction = #selector(leftControllButtonAction)
  940. } else if identifier == KMToolbarMagnifyToolModeItemIdentifier {
  941. item?.titleName = NSLocalizedString("Magnify Tool", comment: "")
  942. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsMagnifier)
  943. item?.target = self
  944. item?.btnTag = KMToolbarViewType.Magnify.rawValue
  945. item?.toolTip = NSLocalizedString("Magnify Tool", comment: "")
  946. item?.boxImagePosition = .imageOnly
  947. item?.btnAction = #selector(leftControllButtonAction)
  948. } else if identifier == KMToolbarSelectToolModeItemIdentifier {
  949. item?.titleName = NSLocalizedString("Content Selection Tool", comment: "")
  950. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsContentsel)
  951. item?.target = self
  952. item?.btnTag = KMToolbarViewType.Select.rawValue
  953. item?.toolTip = NSLocalizedString("Content Selection Tool", comment: "")
  954. item?.boxImagePosition = .imageOnly
  955. item?.btnAction = #selector(leftControllButtonAction)
  956. } else if identifier == KMToolbarZoomToSelectionItemIdentifier {
  957. item?.titleName = NSLocalizedString("Zoom to selected area", comment: "")
  958. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsAreazoom)
  959. item?.target = self
  960. item?.btnTag = KMToolbarViewType.SelectZoom.rawValue
  961. item?.toolTip = NSLocalizedString("Zoom to selected area", comment: "")
  962. item?.boxImagePosition = .imageOnly
  963. item?.btnAction = #selector(leftControllButtonAction)
  964. } else if identifier == KMToolbarHighlightAnnotationItemIdentifier {
  965. item?.titleName = NSLocalizedString("Highlight", comment: "")
  966. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsUnderline)
  967. item?.target = self
  968. item?.btnTag = CAnnotationType.highlight.rawValue
  969. item?.toolTip = String(format: "%@ (⌃⌘H)", NSLocalizedString("Highlight", comment: ""))
  970. item?.boxImagePosition = .imageOnly
  971. item?.btnAction = #selector(changeAnnotationMode)
  972. } else if identifier == KMToolbarUnderlineAnnotationItemIdentifier {
  973. item?.titleName = NSLocalizedString("Underline", comment: "")
  974. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsUnderline)
  975. item?.target = self
  976. item?.btnTag = CAnnotationType.underline.rawValue
  977. item?.toolTip = String(format: "%@ (⇧⌘M)", NSLocalizedString("Underline", comment: ""))
  978. item?.boxImagePosition = .imageOnly
  979. item?.btnAction = #selector(changeAnnotationMode)
  980. } else if identifier == KMToolbarStrikeOutAnnotationItemIdentifier {
  981. item?.titleName = NSLocalizedString("Strikethrough", comment: "")
  982. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsStrikeout)
  983. item?.target = self
  984. item?.btnTag = CAnnotationType.strikeOut.rawValue
  985. item?.toolTip = String(format: "%@ (⌃⌘M)", NSLocalizedString("Strikethrough", comment: ""))
  986. item?.boxImagePosition = .imageOnly
  987. item?.btnAction = #selector(changeAnnotationMode)
  988. } else if identifier == KMToolbarInkAnnotationItemIdentifier {
  989. item?.titleName = NSLocalizedString("Freehand", comment: "")
  990. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsPen)
  991. item?.target = self
  992. item?.btnTag = CAnnotationType.ink.rawValue
  993. item?.toolTip = NSLocalizedString("Add freehand drawings by hand writing just like you do with a pen.", comment: "")
  994. item?.boxImagePosition = .imageOnly
  995. item?.btnAction = #selector(changeAnnotationMode)
  996. } else if identifier == KMToolbarFreeTextAnnotationItemIdentifier {
  997. item?.titleName = NSLocalizedString("Text Note", comment: "")
  998. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsText)
  999. item?.target = self
  1000. item?.btnTag = CAnnotationType.freeText.rawValue
  1001. item?.toolTip = String(format: "%@ (⌘N)", NSLocalizedString("Text Note", comment: ""))
  1002. item?.boxImagePosition = .imageOnly
  1003. item?.btnAction = #selector(changeAnnotationMode)
  1004. } else if identifier == KMToolbarAnchoredAnnotationItemIdentifier {
  1005. item?.titleName = NSLocalizedString("Anchored Note", comment: "")
  1006. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsNote)
  1007. item?.target = self
  1008. item?.btnTag = CAnnotationType.anchored.rawValue
  1009. item?.toolTip = String(format: "%@ (⌥⌘N)", NSLocalizedString("Anchored Note", comment: ""))
  1010. item?.boxImagePosition = .imageOnly
  1011. item?.btnAction = #selector(changeAnnotationMode)
  1012. } else if identifier == KMToolbarSquareAnnotationItemIdentifier {
  1013. item?.titleName = NSLocalizedString("Square", comment: "")
  1014. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsRec)
  1015. item?.target = self
  1016. item?.btnTag = CAnnotationType.square.rawValue
  1017. item?.toolTip = NSLocalizedString("Draw rectangle; draw square by holding Shift key", comment: "")
  1018. item?.boxImagePosition = .imageOnly
  1019. item?.btnAction = #selector(changeAnnotationMode)
  1020. }else if identifier == KMToolbarCircleAnnotationItemIdentifier {
  1021. item?.titleName = NSLocalizedString("oval", comment: "")
  1022. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsOval)
  1023. item?.target = self
  1024. item?.btnTag = CAnnotationType.circle.rawValue
  1025. item?.toolTip = NSLocalizedString("Draw oval; draw circle by holding Shift key", comment: "")
  1026. item?.boxImagePosition = .imageOnly
  1027. item?.btnAction = #selector(changeAnnotationMode)
  1028. } else if identifier == KMToolbarArrowAnnotationItemIdentifier {
  1029. item?.titleName = NSLocalizedString("Arrow", comment: "")
  1030. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsArrow)
  1031. item?.target = self
  1032. item?.btnTag = CAnnotationType.arrow.rawValue
  1033. item?.toolTip = NSLocalizedString("Draw arrow; draw straight arrow by holding Shift key", comment: "")
  1034. item?.boxImagePosition = .imageOnly
  1035. item?.btnAction = #selector(changeAnnotationMode)
  1036. } else if identifier == KMToolbarLineAnnotationItemIdentifier {
  1037. item?.titleName = NSLocalizedString("Square", comment: "")
  1038. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsLine)
  1039. item?.target = self
  1040. item?.btnTag = CAnnotationType.line.rawValue
  1041. item?.toolTip = NSLocalizedString("Draw line; draw straight line by holding Shift key", comment: "")
  1042. item?.boxImagePosition = .imageOnly
  1043. item?.btnAction = #selector(changeAnnotationMode)
  1044. } else if identifier == KMToolbarLinkAnnotationItemIdentifier {
  1045. item?.titleName = NSLocalizedString("Link", comment: "")
  1046. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsLink)
  1047. item?.target = self
  1048. item?.btnTag = CAnnotationType.link.rawValue
  1049. item?.toolTip = NSLocalizedString("Select an area or text on a page for a link to be inserted.", comment: "")
  1050. item?.boxImagePosition = .imageOnly
  1051. item?.btnAction = #selector(changeAnnotationMode)
  1052. } else if identifier == KMToolbarSignSignatureAnnotationItemIdentifier {
  1053. item?.titleName = NSLocalizedString("SignSignature", comment: "")
  1054. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsSign)
  1055. item?.target = self
  1056. item?.btnTag = CAnnotationType.signSignature.rawValue
  1057. item?.toolTip = NSLocalizedString("Add beautiful handwriting or use your trackpad to create your own signature.", comment: "")
  1058. item?.boxImagePosition = .imageOnly
  1059. item?.btnAction = #selector(changeAnnotationMode)
  1060. } else if identifier == KMAnnotationStampToolbarItemIdentifier {
  1061. item?.titleName = NSLocalizedString("Stamp", comment: "")
  1062. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarMytoolsStamp)
  1063. item?.target = self
  1064. item?.btnTag = CAnnotationType.stamp.rawValue
  1065. item?.toolTip = NSLocalizedString("Add New Stamp", comment: "")
  1066. item?.boxImagePosition = .imageOnly
  1067. item?.btnAction = #selector(changeAnnotationMode)
  1068. } else if identifier == KMToolbarShowToolbarItemIdentifier {
  1069. item?.image = NSImage(named: "KMImageNameMainToolShow")
  1070. item?.selectedImage = NSImage(named: "KMImageNameMainToolHide")
  1071. item?.alternateImage = NSImage(named: "KMImageNameMainToolShow")
  1072. item?.selectedBackgroundColor = NSColor.clear
  1073. item?.target = self
  1074. item?.toolTip = NSLocalizedString("Hide", comment: "")
  1075. item?.titleName = NSLocalizedString("Hide", comment: "")
  1076. item?.boxImagePosition = .imageOnly
  1077. item?.btnAction = #selector(showPDFLayoutMode)
  1078. } else if identifier == KMToolbarAnnotationSettingItemIdentifier {
  1079. item?.image = NSImage(named: "KMImageNameUXIconBtnSetNor")
  1080. item?.target = self
  1081. item?.titleName = NSLocalizedString("Setting", comment: "")
  1082. item?.boxImagePosition = .imageOnly
  1083. item?.btnAction = #selector(_itemAction)
  1084. }
  1085. }
  1086. private func _setupEditItem(_ item: KMToolbarItemView?) {
  1087. let identifier = item?.itemIdentifier
  1088. if identifier == KMToolbarAddTextEditPDFItemIdentifier {
  1089. item?.image = NSImage(named: "KMImageNameMainToolFreeText")
  1090. item?.target = self
  1091. item?.btnTag = CAnnotationType.addText.rawValue
  1092. item?.toolTip = NSLocalizedString("Add Text", comment: "")
  1093. item?.titleName = NSLocalizedString("Add Text", comment: "")
  1094. item?.boxImagePosition = .imageLeft
  1095. item?.btnAction = #selector(changeAnnotationMode)
  1096. } else if identifier == KMToolbarAddImageEditPDFItemIdentifier {
  1097. item?.image = NSImage(named: "KMImageNameMainToolEditImage")
  1098. item?.target = self
  1099. item?.btnTag = CAnnotationType.addImage.rawValue
  1100. item?.toolTip = NSLocalizedString("Add Image", comment: "")
  1101. item?.titleName = NSLocalizedString("Add Image", comment: "")
  1102. item?.boxImagePosition = .imageLeft
  1103. item?.btnAction = #selector(changeAnnotationMode)
  1104. }
  1105. }
  1106. private func _setupConvertItem(_ item: KMToolbarItemView?) {
  1107. let identifier = item?.itemIdentifier
  1108. if identifier == KMToolbarConversionWordItemIdentifier {
  1109. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarConvertWord)
  1110. item?.target = self
  1111. item?.btnTag = KMToolbarType.word.rawValue
  1112. item?.toolTip = NSLocalizedString("Convert all the great work stored in your PDF to a Word document that’s easy to update. Keep the fonts and layouts intact — including bullets and tables.", comment: "")
  1113. item?.titleName = NSLocalizedString("To Word", comment: "")
  1114. item?.boxImagePosition = .imageLeft
  1115. item?.btnAction = #selector(conversionMenuItemAction)
  1116. } else if identifier == KMToolbarConversionExcelItemIdentifier {
  1117. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarConvertExcel)
  1118. item?.target = self
  1119. item?.btnTag = KMToolbarType.excel.rawValue
  1120. item?.toolTip = NSLocalizedString("Skip the data entry steps and tedious reformatting tasks, too. When you convert to Excel, your data is preserved along with your columns, layouts, and formatting.", comment: "")
  1121. item?.titleName = NSLocalizedString("To Excel", comment: "")
  1122. item?.boxImagePosition = .imageLeft
  1123. item?.btnAction = #selector(conversionMenuItemAction)
  1124. } else if identifier == KMToolbarConversionPPTItemIdentifier {
  1125. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarConvertPPT)
  1126. item?.target = self
  1127. item?.btnTag = KMToolbarType.ppt.rawValue
  1128. item?.toolTip = NSLocalizedString("When you use PDF Reader Pro to convert PDFs to PowerPoint, you know your formats will be saved, too. So you don’t have to bother redoing bullets, tables, objects, or master layouts.", comment: "")
  1129. item?.titleName = NSLocalizedString("To PPT", comment: "")
  1130. item?.boxImagePosition = .imageLeft
  1131. item?.btnAction = #selector(conversionMenuItemAction)
  1132. } else if identifier == KMToolbarConversionRTFItemIdentifier {
  1133. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarConvertRTF)
  1134. item?.target = self
  1135. item?.btnTag = KMToolbarType.rtf.rawValue
  1136. item?.toolTip = NSLocalizedString("Turn PDF documents into Rich Text Format (RTF) files that can be opened in virtually any word processor.", comment: "")
  1137. item?.titleName = NSLocalizedString("To RTF", comment: "")
  1138. item?.boxImagePosition = .imageLeft
  1139. item?.btnAction = #selector(conversionMenuItemAction)
  1140. } else if identifier == KMToolbarConversionCSVItemIdentifier {
  1141. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarConvertCSV)
  1142. item?.target = self
  1143. item?.btnTag = KMToolbarType.csv.rawValue
  1144. item?.toolTip = NSLocalizedString("PDF To CSV", comment: "")
  1145. item?.titleName = NSLocalizedString("To CSV", comment: "")
  1146. item?.boxImagePosition = .imageLeft
  1147. item?.btnAction = #selector(conversionMenuItemAction)
  1148. } else if identifier == KMToolbarConversionHTMLItemIdentifier {
  1149. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarConvertHtml)
  1150. item?.target = self
  1151. item?.btnTag = KMToolbarType.html.rawValue
  1152. item?.toolTip = NSLocalizedString("PDF To HTML", comment: "")
  1153. item?.titleName = NSLocalizedString("To HTML", comment: "")
  1154. item?.boxImagePosition = .imageLeft
  1155. item?.btnAction = #selector(conversionMenuItemAction)
  1156. } else if identifier == KMToolbarConversionTextItemIdentifier {
  1157. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarConvertText)
  1158. item?.target = self
  1159. item?.btnTag = KMToolbarType.conversion_text.rawValue
  1160. item?.toolTip = NSLocalizedString("PDF To Text", comment: "")
  1161. item?.titleName = NSLocalizedString("To Text", comment: "")
  1162. item?.boxImagePosition = .imageLeft
  1163. item?.btnAction = #selector(conversionMenuItemAction)
  1164. } else if identifier == KMToolbarConversionImageItemIdentifier {
  1165. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarConvertPDFToIMG)
  1166. item?.target = self
  1167. item?.btnTag = KMToolbarType.conversion_image.rawValue
  1168. item?.toolTip = NSLocalizedString("Convert PDF to JPEG, PNG, TIFF, BMP, GIF or TGA files", comment: "")
  1169. item?.titleName = NSLocalizedString("To Image", comment: "")
  1170. item?.boxImagePosition = .imageExpandLeft
  1171. item?.needExpandAction = true
  1172. item?.btnAction = #selector(conversionMenuItemAction)
  1173. let menuItem = NSMenuItem.init(title: "To Image", action: #selector(conversionMenuItemAction), target: self)
  1174. let subMenu = NSMenu()
  1175. subMenu.addItem(title: NSLocalizedString("PDF To JPEG", comment: ""), action: #selector(_pdfToImageAction), target: self, tag: KMPDFConvertType.jpeg.rawValue)
  1176. subMenu.addItem(title: NSLocalizedString("PDF To JPG", comment: ""), action: #selector(_pdfToImageAction), target: self, tag: KMPDFConvertType.jpg.rawValue)
  1177. subMenu.addItem(title: NSLocalizedString("PDF To PNG", comment: ""), action: #selector(_pdfToImageAction), target: self, tag: KMPDFConvertType.png.rawValue)
  1178. subMenu.addItem(title: NSLocalizedString("PDF To GIF", comment: ""), action: #selector(_pdfToImageAction), target: self, tag: KMPDFConvertType.gif.rawValue)
  1179. subMenu.addItem(title: NSLocalizedString("PDF To TIFF", comment: ""), action: #selector(_pdfToImageAction), target: self, tag: KMPDFConvertType.tiff.rawValue)
  1180. subMenu.addItem(title: NSLocalizedString("PDF To TGA", comment: ""), action: #selector(_pdfToImageAction), target: self, tag: KMPDFConvertType.tga.rawValue)
  1181. subMenu.addItem(title: NSLocalizedString("PDF To BMP", comment: ""), action: #selector(_pdfToImageAction), target: self, tag: KMPDFConvertType.bmp.rawValue)
  1182. menuItem.submenu = subMenu
  1183. item?.menuFormRepresentation = menuItem
  1184. } else if item?.itemIdentifier == KMToolbarConversionExportImageItemIdentifier {
  1185. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarConvertExportImage)
  1186. item?.target = self
  1187. item?.toolTip = NSLocalizedString("The range you can extract images includes current page, odd page, even page, custom page, and all pages.", comment: "")
  1188. item?.titleName = NSLocalizedString("Extract Images", comment: "")
  1189. item?.boxImagePosition = .imageExpandLeft
  1190. item?.needExpandAction = true
  1191. let menuItem = NSMenuItem.init(title: "To Image", action: nil, target: self)
  1192. let subMenu = NSMenu()
  1193. subMenu.addItem(title: NSLocalizedString("Extract All Images", comment: ""), action: #selector(_exportImageAction), target: self, tag: 1)
  1194. subMenu.addItem(title: NSLocalizedString("Extract Images", comment: ""), action: #selector(_exportImageAction), target: self, tag: 2)
  1195. menuItem.submenu = subMenu
  1196. item?.menuFormRepresentation = menuItem
  1197. }
  1198. }
  1199. private func _setupFillSignItem(_ item: KMToolbarItemView?) {
  1200. let identifier = item?.itemIdentifier
  1201. if identifier == KMToolbarToolHookItemIdentifier {
  1202. item?.image = NSImage(named: "KMImageNameFillSignHook")
  1203. item?.target = self
  1204. item?.btnTag = CAnnotationType.signTure.rawValue
  1205. item?.toolTip = NSLocalizedString("Signature", comment: "")
  1206. item?.titleName = NSLocalizedString("Signature", comment: "")
  1207. item?.boxImagePosition = .imageOnly
  1208. item?.btnAction = #selector(changeAnnotationMode)
  1209. } else if identifier == KMToolbarToolForkItemIdentifier {
  1210. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarFillsignFork)
  1211. item?.target = self
  1212. item?.btnTag = CAnnotationType.signFalse.rawValue
  1213. item?.toolTip = NSLocalizedString("Add X", comment: "")
  1214. item?.boxImagePosition = .imageOnly
  1215. item?.btnAction = #selector(changeAnnotationMode)
  1216. } else if identifier == KMToolbarToolLineItemIdentifier {
  1217. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarFillsignLine)
  1218. item?.target = self
  1219. item?.btnTag = CAnnotationType.signLine.rawValue
  1220. item?.toolTip = NSLocalizedString("Add line", comment: "")
  1221. item?.boxImagePosition = .imageOnly
  1222. item?.btnAction = #selector(changeAnnotationMode)
  1223. } else if identifier == KMToolbarToolDotItemIdentifier {
  1224. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarFillsignPoint)
  1225. item?.target = self
  1226. item?.btnTag = CAnnotationType.signDot.rawValue
  1227. item?.toolTip = NSLocalizedString("Add dot", comment: "")
  1228. item?.boxImagePosition = .imageOnly
  1229. item?.btnAction = #selector(changeAnnotationMode)
  1230. } else if identifier == KMToolbarToolRectangleIdentifier {
  1231. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarFillsignRoundedrec)
  1232. item?.target = self
  1233. item?.btnTag = CAnnotationType.signCircle.rawValue
  1234. item?.toolTip = NSLocalizedString("Add circle", comment: "")
  1235. item?.boxImagePosition = .imageOnly
  1236. item?.btnAction = #selector(changeAnnotationMode)
  1237. } else if identifier == KMToolbarToolTextIdentifier {
  1238. item?.image = NSImage(named: KMImageNameToolbarFreeText)
  1239. item?.target = self
  1240. item?.btnTag = CAnnotationType.signText.rawValue
  1241. item?.toolTip = NSLocalizedString("Add text", comment: "")
  1242. item?.titleName = NSLocalizedString("Text", comment: "")
  1243. item?.boxImagePosition = .imageOnly
  1244. item?.btnAction = #selector(changeAnnotationMode)
  1245. } else if identifier == KMToolbarToolDateIdentifier {
  1246. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarFillsignDate)
  1247. item?.target = self
  1248. item?.btnTag = CAnnotationType.signDate.rawValue
  1249. item?.toolTip = NSLocalizedString("Date", comment: "")
  1250. item?.boxImagePosition = .imageOnly
  1251. item?.btnAction = #selector(changeAnnotationMode)
  1252. } else if (identifier == KMToolbarToolProfileIdentifier) {
  1253. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarFillsignMyprofile)
  1254. item?.target = self
  1255. item?.toolTip = NSLocalizedString("My Profile", comment: "")
  1256. item?.boxImagePosition = .imageOnly
  1257. item?.btnAction = #selector(_itemAction)
  1258. }else if (identifier == KMToolbarFillSignSignatureIdentifier) {
  1259. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarFillsignMysignature)
  1260. item?.target = self
  1261. item?.btnTag = CAnnotationType.signSignature.rawValue
  1262. item?.toolTip = NSLocalizedString("Sign document by typing or drawing a signature", comment: "")
  1263. item?.boxImagePosition = .imageOnly
  1264. item?.btnAction = #selector(changeAnnotationMode)
  1265. }
  1266. }
  1267. private func _setupFormItem(_ item: KMToolbarItemView?) {
  1268. let identifier = item?.itemIdentifier
  1269. if identifier == KMToolbarToolTextFieldItemIdentifier {
  1270. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarFormTextfield)
  1271. item?.target = self
  1272. item?.btnTag = CAnnotationType.textField.rawValue
  1273. item?.toolTip = NSLocalizedString("Text Field", comment: "")
  1274. item?.titleName = NSLocalizedString("Text Field", comment: "")
  1275. item?.boxImagePosition = .imageLeft
  1276. item?.btnAction = #selector(changeAnnotationMode)
  1277. let menuItem = NSMenuItem.init(title: "TextField", action: #selector(changeAnnotationMode), target: self)
  1278. menuItem.tag = item!.btnTag
  1279. item?.menuFormRepresentation = menuItem
  1280. } else if identifier == KMToolbarToolCheckBoxItemIdentifier {
  1281. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarFormCheckbox)
  1282. item?.target = self
  1283. item?.btnTag = CAnnotationType.checkBox.rawValue
  1284. item?.toolTip = NSLocalizedString("Check Box", comment: "")
  1285. item?.titleName = NSLocalizedString("Check Box", comment: "")
  1286. item?.boxImagePosition = .imageLeft
  1287. item?.btnAction = #selector(changeAnnotationMode)
  1288. } else if identifier == KMToolbarToolRadioButtonItemIdentifier {
  1289. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarFormRadiobutton)
  1290. item?.target = self
  1291. item?.btnTag = CAnnotationType.radioButton.rawValue
  1292. item?.toolTip = NSLocalizedString("Radio Button", comment: "")
  1293. item?.titleName = NSLocalizedString("Radio Button", comment: "")
  1294. item?.boxImagePosition = .imageLeft
  1295. item?.btnAction = #selector(changeAnnotationMode)
  1296. let menuItem = NSMenuItem.init(title: "RadioButton", action: #selector(changeAnnotationMode), target: self)
  1297. menuItem.tag = item!.btnTag
  1298. item?.menuFormRepresentation = menuItem
  1299. } else if identifier == KMToolbarToolListBoxItemIdentifier {
  1300. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarFormListbox)
  1301. item?.target = self
  1302. item?.btnTag = CAnnotationType.listMenu.rawValue
  1303. item?.toolTip = NSLocalizedString("List Box", comment: "")
  1304. item?.titleName = NSLocalizedString("List Box", comment: "")
  1305. item?.boxImagePosition = .imageLeft
  1306. item?.btnAction = #selector(changeAnnotationMode)
  1307. let menuItem = NSMenuItem.init(title: "List Box", action: #selector(changeAnnotationMode), target: self)
  1308. menuItem.tag = item!.btnTag
  1309. item?.menuFormRepresentation = menuItem
  1310. } else if identifier == KMToolbarToolPullDownmenuItemIdentifier {
  1311. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarFormPulldownmenu)
  1312. item?.target = self
  1313. item?.btnTag = CAnnotationType.comboBox.rawValue
  1314. item?.toolTip = NSLocalizedString("Combo Box", comment: "")
  1315. item?.titleName = NSLocalizedString("Combo Box", comment: "")
  1316. item?.boxImagePosition = .imageLeft
  1317. item?.btnAction = #selector(changeAnnotationMode)
  1318. let menuItem = NSMenuItem.init(title: "PullDownmenu", action: #selector(changeAnnotationMode), target: self)
  1319. menuItem.tag = item!.btnTag
  1320. item?.menuFormRepresentation = menuItem
  1321. } else if identifier == KMToolbarToolButtonIdentifier {
  1322. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarFormButton)
  1323. item?.target = self
  1324. item?.btnTag = CAnnotationType.actionButton.rawValue
  1325. item?.toolTip = NSLocalizedString("Button", comment: "")
  1326. item?.titleName = NSLocalizedString("Button", comment: "")
  1327. item?.boxImagePosition = .imageLeft
  1328. item?.btnAction = #selector(changeAnnotationMode)
  1329. let menuItem = NSMenuItem.init(title: "Button", action: #selector(changeAnnotationMode), target: self)
  1330. menuItem.tag = item!.btnTag
  1331. item?.menuFormRepresentation = menuItem
  1332. } else if identifier == KMToolbarToolSignBoxIdentifier {
  1333. item?.image = NSImage(named: KMImageNameUXIconSubtoolbarFormSign)
  1334. item?.target = self
  1335. item?.btnTag = CAnnotationType.signature.rawValue
  1336. item?.toolTip = NSLocalizedString("Signature", comment: "")
  1337. item?.titleName = NSLocalizedString("Signature", comment: "")
  1338. item?.boxImagePosition = .imageLeft
  1339. item?.btnAction = #selector(changeAnnotationMode)
  1340. let menuItem = NSMenuItem.init(title: "SignBox", action: #selector(changeAnnotationMode), target: self)
  1341. menuItem.tag = item!.btnTag
  1342. item?.menuFormRepresentation = menuItem
  1343. } else if identifier == KMToolbarToolFormAlignIdentifier {
  1344. item?.image = NSImage(named: KMImageNameUXIconPropertybarAlignLeftToor)
  1345. item?.target = self
  1346. item?.toolTip = NSLocalizedString("Alignment", comment: "")
  1347. item?.titleName = NSLocalizedString("Alignment", comment: "")
  1348. item?.boxImagePosition = .imageExpandLeft
  1349. item?.needExpandAction = true
  1350. item?.btnAction = #selector(formsAlignmentAction)
  1351. let menuItem = NSMenuItem.init(title: "Alignment", action: #selector(formsAlignmentAction), target: self)
  1352. let subMenu = NSMenu()
  1353. subMenu.addItem(title: NSLocalizedString("Align Left", comment: ""), imageNamed: "KMImageNameUXIconPropertybarAlignLeftNor", action: #selector(_alignmentAction), target: self, tag: 0)
  1354. subMenu.addItem(title: NSLocalizedString("Align Vertically", comment: ""), imageNamed: "KMImageNameUXIconPropertybarAlignVercenterNor", action: #selector(_alignmentAction), target: self, tag: 1)
  1355. subMenu.addItem(title: NSLocalizedString("Align Right", comment: ""), imageNamed: "KMImageNameUXIconPropertybarAlignRightNor", action: #selector(_alignmentAction), target: self, tag: 2)
  1356. subMenu.addItem(NSMenuItem.separator())
  1357. subMenu.addItem(title: NSLocalizedString("Align Top", comment: ""), imageNamed: "KMImageNameUXIconPropertybarAlignUpNor", action: #selector(_alignmentAction), target: self, tag: 3)
  1358. subMenu.addItem(title: NSLocalizedString("Align Horizontally", comment: ""), imageNamed: "KMImageNameUXIconPropertybarAlignHorcenterNor", action: #selector(_alignmentAction), target: self, tag: 4)
  1359. subMenu.addItem(title: NSLocalizedString("Align Bottom", comment: ""), imageNamed: "KMImageNameUXIconPropertybarAlignDownNor", action: #selector(_alignmentAction), target: self, tag: 5)
  1360. subMenu.addItem(NSMenuItem.separator())
  1361. subMenu.addItem(title: NSLocalizedString("Distribute Horizontally", comment: ""), imageNamed: "KMImageNameUXIconPropertybarAlignHorsplitNor", action: #selector(_alignmentAction), target: self, tag: 6)
  1362. subMenu.addItem(title: NSLocalizedString("Distribute Vertically", comment: ""), imageNamed: "KMImageNameUXIconPropertybarAlignVersplitNor", action: #selector(_alignmentAction), target: self, tag: 7)
  1363. menuItem.submenu = subMenu
  1364. menuItem.tag = item!.btnTag
  1365. item?.menuFormRepresentation = menuItem
  1366. } else if identifier == KMToolbarToolFormMoreIdentifier {
  1367. item?.image = NSImage(named: "KMImageNameMainToolFormMore")
  1368. item?.target = self
  1369. item?.toolTip = NSLocalizedString("More", comment: "")
  1370. item?.titleName = NSLocalizedString("More", comment: "")
  1371. item?.boxImagePosition = .imageExpandLeft
  1372. item?.btnAction = #selector(formsMoreOperationAction)
  1373. let menuItem = NSMenuItem.init(title: "More", action: #selector(formsMoreOperationAction), target: self)
  1374. menuItem.tag = item!.btnTag
  1375. item?.menuFormRepresentation = menuItem
  1376. }
  1377. }
  1378. private func _setupToolItem(_ item: KMToolbarItemView?) {
  1379. let identifier = item?.itemIdentifier
  1380. if identifier == KMToolbarToolCropItemIdentifier {
  1381. item?.image = NSImage(named: "KMImageNameMainToolsCrop")
  1382. item?.alternateImage = NSImage(named: "KMImageNameMainToolsCrop")
  1383. item?.target = self
  1384. item?.btnTag = KMToolbarType.crop.rawValue
  1385. item?.toolTip = NSLocalizedString("Crop pages", comment: "")
  1386. item?.titleName = NSLocalizedString("Crop", comment: "")
  1387. item?.boxImagePosition = .imageExpandLeft
  1388. item?.btnAction = #selector(cropMenuAction)
  1389. let menuItem = NSMenuItem.init(title: "Crop", action: #selector(cropMenuAction), target: self)
  1390. item?.menuFormRepresentation = menuItem
  1391. } else if identifier == KMToolbarComparisonItemIdentifier {
  1392. item?.image = NSImage(named: KMImageNameUXIconBatchComparison)
  1393. item?.target = self
  1394. item?.btnTag = KMToolbarType.comparison.rawValue
  1395. item?.toolTip = NSLocalizedString("Compare", comment: "")
  1396. item?.titleName = NSLocalizedString("Compare", comment: "")
  1397. item?.boxImagePosition = .imageExpandLeft
  1398. item?.btnAction = #selector(_itemAction)
  1399. let menuItem = NSMenuItem.init(title: "Bates Number", action: #selector(batesMenuAction), target: self)
  1400. let subMenu = NSMenu()
  1401. subMenu.addItem(title: NSLocalizedString("Side-by-Side View", comment: ""), action: #selector(_comparisonAction), target: self, tag: 1)
  1402. subMenu.addItem(title: NSLocalizedString("Compare by File Overlay", comment: ""), action: #selector(_comparisonAction), target: self, tag: 2)
  1403. menuItem.submenu = subMenu
  1404. item?.menuFormRepresentation = menuItem
  1405. } else if identifier == KMToolbarToolBatesItemIdentifier {
  1406. item?.image = NSImage(named: "KMImageNameUXIconBatchBatesNor")
  1407. item?.target = self
  1408. item?.btnTag = KMToolbarType.bates.rawValue
  1409. item?.toolTip = NSLocalizedString("Add PDF Bates numbering to your legal, medical, or business documents", comment: "")
  1410. item?.titleName = NSLocalizedString("Bates Number", comment: "")
  1411. item?.boxImagePosition = .imageExpandLeft
  1412. item?.needExpandAction = true
  1413. item?.btnAction = #selector(batesMenuAction)
  1414. let menuItem = NSMenuItem.init(title: "Bates Number", action: #selector(batesMenuAction), target: self)
  1415. let subMenu = NSMenu()
  1416. subMenu.addItem(title: NSLocalizedString("Add Bates Numbers", comment: ""), action: #selector(_batesAction), target: self, tag: 1)
  1417. subMenu.addItem(title: NSLocalizedString("Remove Bates Numbers", comment: ""), action: #selector(_batesAction), target: self, tag: 2)
  1418. subMenu.addItem(title: NSLocalizedString("Batch Add Batch Numbers", comment: ""), action: #selector(_batesAction), target: self, tag: 3)
  1419. subMenu.addItem(title: NSLocalizedString("Batch Remove Bates Numbers", comment: ""), action: #selector(_batesAction), target: self, tag: 4)
  1420. subMenu.addItem(title: NSLocalizedString("Manage Templates", comment: ""), action: #selector(_batesAction), target: self, tag: 5)
  1421. menuItem.submenu = subMenu
  1422. item?.menuFormRepresentation = menuItem
  1423. } else if identifier == KMToolbarToolHeaderFooterItemIdentifier {
  1424. item?.image = NSImage(named: "KMImageNameUXIconBatchHeaderandfooterNor")
  1425. item?.target = self
  1426. item?.btnTag = KMToolbarType.headerAndFooter.rawValue
  1427. item?.toolTip = NSLocalizedString("Insert header, footer, and page numbers to PDF", comment: "")
  1428. item?.titleName = NSLocalizedString("Header & Footer", comment: "")
  1429. item?.boxImagePosition = .imageExpandLeft
  1430. item?.needExpandAction = true
  1431. item?.btnAction = #selector(headerfooterMenuAction)
  1432. let menuItem = NSMenuItem.init(title: "Header & Footer", action: #selector(headerfooterMenuAction), target: self)
  1433. let subMenu = NSMenu()
  1434. subMenu.addItem(title: NSLocalizedString("Add Header & Footer", comment: ""), action: #selector(_headerfooterAction), target: self, tag: 1)
  1435. subMenu.addItem(title: NSLocalizedString("Remove Header & Footer", comment: ""), action: #selector(_headerfooterAction), target: self, tag: 2)
  1436. subMenu.addItem(title: NSLocalizedString("Batch Add Header & Footer", comment: ""), action: #selector(_headerfooterAction), target: self, tag: 3)
  1437. subMenu.addItem(title: NSLocalizedString("Batch Remove Header & Footer", comment: ""), action: #selector(_headerfooterAction), target: self, tag: 4)
  1438. subMenu.addItem(title: NSLocalizedString("Manage Templates", comment: ""), action: #selector(_headerfooterAction), target: self, tag: 5)
  1439. menuItem.submenu = subMenu
  1440. item?.menuFormRepresentation = menuItem
  1441. } else if identifier == KMToolbarToolBackgroundItemIdentifier {
  1442. item?.image = NSImage(named: "KMImageNameUXIconBatchBackgroundNor")
  1443. item?.target = self
  1444. item?.btnTag = KMToolbarType.background.rawValue
  1445. item?.toolTip = NSLocalizedString("Insert PDF page background by color or image", comment: "")
  1446. item?.titleName = NSLocalizedString("Backgroud", comment: "")
  1447. item?.boxImagePosition = .imageExpandLeft
  1448. item?.needExpandAction = true
  1449. item?.btnAction = #selector(backgroundMenuAction)
  1450. let menuItem = NSMenuItem.init(title: "Backgroud", action: #selector(backgroundMenuAction), target: self)
  1451. let subMenu = NSMenu()
  1452. subMenu.addItem(title: NSLocalizedString("Add Background", comment: ""), action: #selector(_backgroundAction), target: self, tag: 1)
  1453. subMenu.addItem(title: NSLocalizedString("Remove Background", comment: ""), action: #selector(_backgroundAction), target: self, tag: 2)
  1454. subMenu.addItem(title: NSLocalizedString("Batch Add Background", comment: ""), action: #selector(_backgroundAction), target: self, tag: 3)
  1455. subMenu.addItem(title: NSLocalizedString("Batch Remove Background", comment: ""), action: #selector(_backgroundAction), target: self, tag: 4)
  1456. subMenu.addItem(title: NSLocalizedString("Manage Templates", comment: ""), action: #selector(_backgroundAction), target: self, tag: 5)
  1457. menuItem.submenu = subMenu
  1458. item?.menuFormRepresentation = menuItem
  1459. } else if identifier == KMToolbarToolWatermarkItemIdentifier {
  1460. item?.image = NSImage(named: "KMImageNameMainToolsWatermark")
  1461. item?.target = self
  1462. item?.btnTag = KMToolbarType.watermark.rawValue
  1463. item?.toolTip = NSLocalizedString("Watermark", comment: "")
  1464. item?.titleName = NSLocalizedString("Watermark", comment: "")
  1465. item?.boxImagePosition = .imageExpandLeft
  1466. item?.needExpandAction = true
  1467. item?.btnAction = #selector(watermarkMenuAction)
  1468. let menuItem = NSMenuItem.init(title: "Watermark", action: #selector(watermarkMenuAction), target: self)
  1469. let subMenu = NSMenu()
  1470. subMenu.addItem(title: NSLocalizedString("Add Watermark", comment: ""), action: #selector(_watermarkAction), target: self, tag: 1)
  1471. subMenu.addItem(title: NSLocalizedString("Remove Watermark", comment: ""), action: #selector(_watermarkAction), target: self, tag: 2)
  1472. subMenu.addItem(title: NSLocalizedString("Batch Add Watermarks", comment: ""), action: #selector(_watermarkAction), target: self, tag: 3)
  1473. subMenu.addItem(title: NSLocalizedString("Batch Remove Watermarks", comment: ""), action: #selector(_watermarkAction), target: self, tag: 4)
  1474. subMenu.addItem(title: NSLocalizedString("Manage Templates", comment: ""), action: #selector(_watermarkAction), target: self, tag: 5)
  1475. menuItem.submenu = subMenu
  1476. item?.menuFormRepresentation = menuItem
  1477. } else if identifier == KMToolbarToolCompressItemIdentifier {
  1478. item?.image = NSImage(named: "KMImageNameUXIconBatchOptimizeNor")
  1479. item?.target = self
  1480. item?.btnTag = KMToolbarType.compress.rawValue
  1481. item?.boxImagePosition = .imageLeft
  1482. item?.toolTip = NSLocalizedString("Reduce file size", comment: "")
  1483. item?.titleName = NSLocalizedString("Compress", comment: "")
  1484. item?.btnAction = #selector(compressMenuAction)
  1485. } else if identifier == KMToolbarToolSecureItemIdentifier {
  1486. item?.image = NSImage(named: "KMImageNameUXIconBatchSafeNor")
  1487. item?.target = self
  1488. item?.toolTip = NSLocalizedString("Batch encrypting PDF documents", comment: "")
  1489. item?.titleName = NSLocalizedString("Security", comment: "")
  1490. item?.boxImagePosition = .imageExpandLeft
  1491. item?.needExpandAction = true
  1492. item?.btnAction = #selector(secureMenuAction)
  1493. let menuItem = NSMenuItem.init(title: "Security", action: #selector(secureMenuAction), target: self)
  1494. menuItem.tag = item!.btnTag
  1495. item?.menuFormRepresentation = menuItem
  1496. }else if identifier == KMToolbarToolMergeItemIdentifier {
  1497. item?.image = NSImage(named: "KMImageNameUXIconBatchMergeNor")
  1498. item?.target = self
  1499. item?.btnTag = KMToolbarType.merge.rawValue
  1500. item?.toolTip = NSLocalizedString("Combine multiple documents into a new PDF, or borrow individual pages", comment: "")
  1501. item?.titleName = NSLocalizedString("Merge", comment: "")
  1502. item?.boxImagePosition = .imageLeft
  1503. item?.btnAction = #selector(mergeMenuItemAction)
  1504. }
  1505. }
  1506. }