1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495 |
- //
- // KMToolbarViewController.swift
- // PDF Master
- //
- // Created by lxy on 2022/12/2.
- //
- import Cocoa
- @objc enum KMToolbarViewType : Int {
- case None
- case Main
- case Annatiton
- case Page
- case Conversion
- case ScanOCR
- case editPDF
- case Form
- case FillSign
- case Tool
- case Move
- case Magnify
- case Select
- case SelectZoom
- case LeftPanel
- case RightPanel
-
- func isToolMode() -> Bool {
- return (self == .Move || self == .Magnify || self == .Select || self == .SelectZoom)
- }
-
- func itemIdentifier() -> String {
- if (self == .Annatiton) {
- return KMDocumentAnnotationToolbarItemIdentifier
- } else if (self == .Page) {
- return KMDocumentPageToolbarItemIdentifier
- } else if (self == .Conversion) {
- return KMDocumentConversonToolbarItemIdentifier
- } else if (self == .ScanOCR) {
- return KMDocumentScanOCRToolbarItemIdentifier
- } else if (self == .editPDF) {
- return KMDocumentEditToolbarItemIdentifier
- } else if (self == .Form) {
- return KMDocumentFormToolbarItemIdentifier
- } else if (self == .FillSign) {
- return KMDocumentFillSginToolbarItemIdentifier
- } else if (self == .Tool) {
- return KMDocumentToolToolbarItemIdentifier
- } else if (self == .Move) {
- return KMToolbarMoveToolModeItemIdentifier
- } else if (self == .Magnify) {
- return KMToolbarMagnifyToolModeItemIdentifier
- } else if (self == .Select) {
- return KMToolbarSelectToolModeItemIdentifier
- } else if (self == .SelectZoom) {
- return KMToolbarZoomToSelectionItemIdentifier
- } else if (self == .LeftPanel) {
- return KMLeftControlToolbarItemIdentifier
- } else if (self == .RightPanel) {
- return KMRightControlToolbarItemIdentifier
- }
- return ""
- }
- }
- @objc enum KMToolbarType: Int {
- /// conversion
- case word = 3000
- case excel = 3001
- case ppt = 3002
- case rtf = 3003
- case csv = 3004
- case html = 3005
- case conversion_text = 3006
- case conversion_image = 3007
-
- /// tool
- case compress = 8000
- case merge = 8001
- case fileCompare = 8002
- case secure = 8003
- case redact = 8004
- case watermark = 8005
- case background = 8006
- case headerAndFooter = 8007
- case bates = 8008
- case crop = 8009
- }
- @objc protocol KMToolbarViewControllerDelegate {
- @objc optional func changeAnnotationModeAction(item:KMToolbarClickButton)
- @objc optional func showPDFLayoutModeAction(show:Bool)
- @objc optional func changePDFViewZoomInAction()
- @objc optional func changePDFViewZoomOutAction()
- @objc optional func changePDFViewGotoNextPageAction()
- @objc optional func changePDFViewGoToPreviousPageAction()
- @objc optional func showPDFViewPrintViewController()
- @objc optional func aiTranslationPDFFileAction()
- @objc optional func toolbarViewController(_ viewController:KMToolbarViewController, zoomSting : String)
- @objc optional func toolbarViewController(_ viewController:KMToolbarViewController, zoomModel selectedTag:Int)
- @objc optional func toolbarViewController(_ viewController:KMToolbarViewController, shareDocument item:NSMenuItem)
- @objc optional func toolbarViewController(_ viewController:KMToolbarViewController, shareFlatten item:NSMenuItem)
- @objc optional func toolbarViewController(_ viewController:KMToolbarViewController, shareOriginalPDF item:NSMenuItem)
- @objc optional func toolbarViewController(_ viewController: KMToolbarViewController, clickMode toolMode: KMToolbarViewType, toolbar toolbarItem: KMToolBoxItem, _ pages: [Int])
- @objc optional func toolbarViewController(_ viewController: KMToolbarViewController, clickChaildToolType: KMToolbarType, toolbar toolbarItem: KMToolBoxItem)
- @objc optional func toolbarViewController(_ viewController:KMToolbarViewController, scanOCRModel selectedTag:Int)
- @objc optional func toolbarViewController(_ viewController:KMToolbarViewController, rightPanel toolbarItem: KMToolBoxItem)
- @objc optional func toolbarViewController(_ viewController:KMToolbarViewController, leftPanel toolbarItem: KMToolBoxItem)
- }
- class KMToolbarViewController: NSViewController, NSTextFieldDelegate {
- var toolbar : KMToolbar!
- var toolbarType : KMToolbarViewType = KMToolbarViewType.None
- var toolbarItems : [String : Any] = [:]
- @IBOutlet weak var mainWindowController : MainWindowController!
- open weak var delegate: KMToolbarViewControllerDelegate?
- @IBOutlet var zoomButton: NSPopUpButton!
- @IBOutlet var zoomView: NSView!
- @IBOutlet weak var zoomTextField: NSTextField!
- var pdfView : CPDFListView = CPDFListView()
- var shareButton = KMToolbarClickButton()
- private var bottomLine = NSView()
-
- // 是否显示所有注释
- var isShowAllAnnotations = true
- var ignoreCurrentAnnotationTypeChange = false
-
- override func viewDidLoad() {
- super.viewDidLoad()
- self.zoomTextField.delegate = self
- NotificationCenter.default.addObserver(self, selector: #selector(listViewAnnotationTypeChangeNotification), name: Notification.Name("CPDFListViewAnnotationTypeChangeNotification"), object: nil)
- NotificationCenter.default.addObserver(self, selector: #selector(listViewAnnotationTypeChangeNotification), name: Notification.Name("CPDFListViewToolModeChangeNotification"), object: nil)
- }
-
- override func loadView() {
- super.loadView()
-
- self.toolbar = KMToolbar.init(identifier: "KMToolbar_New")
- self.toolbar.frame = self.view.bounds
- self.toolbar.autoresizingMask = [.width,.height]
- self.toolbar.delegate = self
- self.view.addSubview(self.toolbar)
-
- self.view.addSubview(self.bottomLine)
- self.bottomLine.frame = NSMakeRect(0, 0, NSWidth(self.view.bounds), 1)
- self.bottomLine.autoresizingMask = [.width]
- self.bottomLine.wantsLayer = true
- self.bottomLine.layer?.backgroundColor = NSColor(hex: "#0000001A").cgColor
- }
-
- func updateType(newType:KMToolbarViewType) {
- if newType != toolbarType {
- toolbarType = newType
- if self.toolbar != nil && self.toolbar.superview != nil {
- self.toolbar.removeFromSuperview()
- }
- self.toolbar = KMToolbar.init(identifier: "KMToolbar_New")
- self.toolbar.frame = self.view.bounds
- self.toolbar.autoresizingMask = [.width,.height]
- self.toolbar.delegate = self
- self.view.addSubview(self.toolbar)
- }
- }
-
- func reloadateToolbar() -> Void {
- toolbar.reloadData()
- }
-
- func resetToolbar() -> Void {
- for item in toolbar.items {
- item.isSelected = false
- }
- }
-
- // MARK: Action
-
- @IBAction func changeAnnotationMode(item: KMToolbarClickButton) {
- self.delegate?.changeAnnotationModeAction?(item: item)
- }
-
- @IBAction func leftControllButtonAction(item: KMToolbarClickButton) {
-
- let tag = KMToolbarViewType(rawValue: item.tag) ?? .None
-
- if tag == .editPDF {
- Task { @MainActor in
- if await (KMLightMemberManager.manager.canUseAdvanced() == false) {
- let _ = KMComparativeTableViewController.show(window: self.view.window!)
- return
- }
- self.delegate?.toolbarViewController?(self, clickMode: tag, toolbar: item.clickObject as! KMToolBoxItem, [])
- }
- } else {
- self.delegate?.toolbarViewController?(self, clickMode: tag, toolbar: item.clickObject as! KMToolBoxItem, [])
- }
- }
-
- @objc private func leftPanelAction(sender: KMToolbarClickButton) {
- self.delegate?.toolbarViewController?(self, leftPanel: sender.clickObject as! KMToolBoxItem)
- }
-
- @IBAction func rightPanelControllButtonAction(item: KMToolbarClickButton) {
- let tag = KMToolbarViewType(rawValue: item.tag) ?? .None
-
- self.delegate?.toolbarViewController?(self, rightPanel: item.clickObject as! KMToolBoxItem)
- }
-
- @IBAction func showPDFLayoutMode(sender: KMToolbarClickButton) {
- let item = sender.clickObject as? KMToolBoxItem
- if (item != nil) {
- item?.isSelected = !item!.isSelected
- }
- self.delegate?.showPDFLayoutModeAction?(show: true)
- }
-
- @objc func cropMenuAction(item: KMToolBoxItem) {
- self.delegate?.toolbarViewController?(self, clickChaildToolType: .crop, toolbar: item)
- }
-
- @objc func batesMenuAction(sender: KMToolbarClickButton) {
- self.delegate?.toolbarViewController?(self, clickChaildToolType: .bates, toolbar: sender.clickObject as! KMToolBoxItem)
- }
-
- @objc func headerfooterMenuAction(sender: KMToolbarClickButton) {
- self.delegate?.toolbarViewController?(self, clickChaildToolType: .headerAndFooter, toolbar: sender.clickObject as! KMToolBoxItem)
- }
-
- @objc func backgroundMenuAction(sender: KMToolbarClickButton) {
- self.delegate?.toolbarViewController?(self, clickChaildToolType: .background, toolbar: sender.clickObject as! KMToolBoxItem)
- }
-
- @objc func watermarkMenuAction(sender: KMToolbarClickButton) {
- self.delegate?.toolbarViewController?(self, clickChaildToolType: .watermark, toolbar: sender.clickObject as! KMToolBoxItem)
- }
-
- @objc func redactMenuAction(sender: KMToolbarClickButton) {
- self.delegate?.toolbarViewController?(self, clickChaildToolType: .redact, toolbar: sender.clickObject as! KMToolBoxItem)
- }
-
- @objc func compressMenuAction(sender: KMToolbarClickButton) {
- self.delegate?.toolbarViewController?(self, clickChaildToolType: .compress, toolbar: sender.clickObject as! KMToolBoxItem)
- }
-
- @objc func secureMenuAction(sender: KMToolbarClickButton) {
- self.delegate?.toolbarViewController?(self, clickChaildToolType: .secure, toolbar: sender.clickObject as! KMToolBoxItem)
- }
-
- @objc func conversionMenuItemAction(sender: KMToolbarClickButton) {
- let item: KMToolBoxItem = sender.clickObject as! KMToolBoxItem
- var type: KMToolbarType = .word
- if (item.btnTag == KMToolbarType.excel.rawValue) {
- type = .excel
- } else if (item.btnTag == KMToolbarType.ppt.rawValue) {
- type = .ppt
- } else if (item.btnTag == KMToolbarType.rtf.rawValue) {
- type = .rtf
- } else if (item.btnTag == KMToolbarType.csv.rawValue) {
- type = .csv
- } else if (item.btnTag == KMToolbarType.html.rawValue) {
- type = .html
- } else if (item.btnTag == KMToolbarType.conversion_text.rawValue) {
- type = .conversion_text
- } else if (item.btnTag == KMToolbarType.conversion_image.rawValue) {
- type = .conversion_image
- }
- self.delegate?.toolbarViewController?(self, clickChaildToolType: type, toolbar: item)
- }
-
-
- @IBAction func zoomModelSelectButtonAction(_ sender: NSPopUpButton) {
- self.delegate?.toolbarViewController?(self, zoomModel: sender.selectedTag())
- for item in sender.itemArray {
- item.state = .off
- }
- sender.selectedItem?.state = .on
- }
-
- @IBAction func zoomPDFViewButtonAction(sender:KMToolbarClickButton) {
- if sender.tag == 0 {
- self.delegate?.changePDFViewZoomOutAction?()
- } else if sender.tag == 1 {
- self.delegate?.changePDFViewZoomInAction?()
- } else if sender.tag == 2 {
- self.delegate?.changePDFViewGotoNextPageAction?()
- } else if sender.tag == 3 {
- self.delegate?.changePDFViewGoToPreviousPageAction?()
- }
- }
-
- @IBAction func printPDFViewButtonAction(sender:KMToolbarClickButton) {
- self.delegate?.showPDFViewPrintViewController?()
- }
-
- @IBAction func aiTranslationButtonAction(sender:KMToolbarClickButton) {
- self.delegate?.aiTranslationPDFFileAction?()
- }
-
- @IBAction func shareButtonAction(sender:KMToolbarClickButton) {
- self.shareButton = sender
- let menu = NSMenu()
- menu.addItem(withTitle: NSLocalizedString("Document", comment: ""), action: #selector(shareViaWithDocument), target: self)
- menu.addItem(withTitle: NSLocalizedString("Flattened Copy", comment: ""), action: #selector(shareViaWithFlatten), target: self)
- menu.addItem(withTitle: NSLocalizedString("Original PDF", comment: ""), action: #selector(shareViaWithOriginalPDF), target: self)
- menu.popUp(positioning: nil, at: NSPoint(x: sender.frame.origin.x, y: sender.frame.origin.y-10), in: sender.superview)
- }
-
- @IBAction func shareViaWithDocument(sender:NSMenuItem) {
- self.delegate?.toolbarViewController?(self, shareDocument: sender)
- }
-
- @IBAction func shareViaWithFlatten(sender:NSMenuItem) {
- self.delegate?.toolbarViewController?(self, shareFlatten: sender)
- }
-
- @IBAction func shareViaWithOriginalPDF(sender:NSMenuItem) {
- self.delegate?.toolbarViewController?(self, shareOriginalPDF: sender)
- }
-
- @objc func mergeMenuItemAction(sender: KMToolbarClickButton) {
- self.delegate?.toolbarViewController?(self, clickChaildToolType: .merge, toolbar: sender.clickObject as! KMToolBoxItem)
- }
-
- @IBAction func scanOCRModelSelect(sender:KMToolbarClickButton) {
- self.delegate?.toolbarViewController?(self, scanOCRModel: sender.tag)
- }
-
- // Form 对齐
- @IBAction func formsAlignmentAction(sender:KMToolbarClickButton) {
-
- }
-
- // Form 更多操作
- @IBAction func formsMoreOperationAction(sender:KMToolbarClickButton) {
-
- }
-
- func toolbarItemFindItemIdentifiers(value : String) -> KMToolBoxItem{
- for item in self.toolbarItems {
- if item.key == value {
- return item.value as! KMToolBoxItem
- }
- }
- return KMToolBoxItem()
- }
-
- func controlTextDidEndEditing(_ obj: Notification) {
- let textField = obj.object as? NSTextField
- if textField == self.zoomTextField {
- self.delegate?.toolbarViewController?(self, zoomSting: self.zoomTextField.stringValue)
- }
- }
-
- func controlTextDidChange(_ obj: Notification) {
-
- }
-
- func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
- switch commandSelector {
- case #selector(NSResponder.insertNewline(_:)):
- if let inputView = control as? NSTextField {
- // //当当前TextField按下enter
- if inputView == zoomTextField {
- print("按下 enter")
- self.delegate?.toolbarViewController?(self, zoomSting: self.zoomTextField.stringValue)
- }
- }
- return true
- default:
- return false
- }
- }
- }
- extension KMToolbarViewController : KMNewToolbarDelegate,NSToolbarItemValidation {
- func toolbarLeftDefaultItemIdentifiers(_ toolbar: KMToolbar!) -> [String]! {
- if toolbarType == .Main {
- return [KMLeftControlToolbarItemIdentifier, KMToolbarDividerItemIdentifier,
- KMDocumentZoomToolbarItemIdentifier,
- KMDocumentZoomOutToolbarItemIdentifier,
- KMDocumentZoomViewToolbarItemIdentifier, KMToolbarDividerItemIdentifier]
- }
- return []
- }
-
- func toolbarRightDefaultItemIdentifiers(_ toolbar: KMToolbar!) -> [String]! {
- if toolbarType == .Main {
- return [KMDocumentAITranslationToolbarItemIdentifier,
- KMDocumentPrintToolbarItemIdentifier,
- KMDocumentShareToolbarItemIdentifier,
- KMRightControlToolbarItemIdentifier]
- }
- return []
- }
-
- func toolbarDefaultItemIdentifiers(_ toolbar: KMToolbar!) -> [String]! {
- switch toolbarType {
- case .None:
- return []
- case .Main:
- return [KMDocumentAnnotationToolbarItemIdentifier,
- KMDocumentEditToolbarItemIdentifier,
- KMDocumentPageToolbarItemIdentifier,
- KMDocumentConversonToolbarItemIdentifier,
- // KMDocumentFillSginToolbarItemIdentifier,
- KMDocumentToolToolbarItemIdentifier]
- case .Annatiton,.Magnify,.Move,.Select,.SelectZoom:
- return [KMToolbarMoveToolModeItemIdentifier,
- KMToolbarMagnifyToolModeItemIdentifier,
- KMToolbarSelectToolModeItemIdentifier,
- KMToolbarZoomToSelectionItemIdentifier,
- KMNewToolbarSpaceItemIdentifier,
- KMToolbarDividerItemIdentifier,
- KMNewToolbarSpaceItemIdentifier,
- KMToolbarHighlightAnnotationItemIdentifier,
- KMToolbarUnderlineAnnotationItemIdentifier,
- KMToolbarStrikeOutAnnotationItemIdentifier,
- KMToolbarInkAnnotationItemIdentifier,
- KMToolbarFreeTextAnnotationItemIdentifier,
- KMToolbarAnchoredAnnotationItemIdentifier,
- KMToolbarSquareAnnotationItemIdentifier,
- KMToolbarLinkAnnotationItemIdentifier,
- KMAnnotationStampToolbarItemIdentifier,
- KMToolbarSignSignatureAnnotationItemIdentifier,
- KMToolbarDividerItemIdentifier,
- KMToolbarShowToolbarItemIdentifier]
- case .editPDF:
- return [KMToolbarAddTextEditPDFItemIdentifier,
- KMToolbarAddImageEditPDFItemIdentifier]
- case .Page:
- return []
- case .Tool:
- return [KMToolbarToolCompressItemIdentifier,
- KMToolbarToolMergeItemIdentifier,
- KMToolbarToolSecureItemIdentifier,
- KMToolbarToolCropItemIdentifier]
- case .Form:
- return [KMToolbarToolTextFieldItemIdentifier,
- KMToolbarToolCheckBoxItemIdentifier,
- KMToolbarToolRadioButtonItemIdentifier,
- KMToolbarToolListBoxItemIdentifier,
- KMToolbarToolPullDownmenuItemIdentifier,
- KMToolbarToolButtonIdentifier,
- KMToolbarToolSignBoxIdentifier,
- KMToolbarDividerItemIdentifier,
- KMToolbarToolFormAlignIdentifier,
- KMToolbarToolFormMoreIdentifier]
- case .FillSign:
- return [KMToolbarToolTextIdentifier,
- KMToolbarToolHookItemIdentifier,
- KMToolbarToolForkItemIdentifier,
- KMToolbarToolRectangleIdentifier,
- KMToolbarToolLineItemIdentifier,
- KMToolbarToolDotItemIdentifier,
- KMToolbarToolDateIdentifier,
- KMToolbarFillSignSignatureIdentifier]
- case .Conversion:
- return [KMToolbarConversionWordItemIdentifier,
- KMToolbarConversionExcelItemIdentifier,
- KMToolbarConversionPPTItemIdentifier,
- KMToolbarConversionRTFItemIdentifier,
- KMToolbarConversionCSVItemIdentifier,
- KMToolbarConversionHTMLItemIdentifier,
- KMToolbarConversionTextItemIdentifier,
- KMToolbarConversionImageItemIdentifier]
- case .ScanOCR:
- return [KMToolbarToolEnhancedScanIdentifier,
- KMToolbarToolOCRTextIdentifier]
- default:
- break
- }
- return []
- }
-
- func toolbar(_ toolbar: KMToolbar!, itemForItemIdentifier identifier: String!) -> KMToolBoxItem! {
- var item = self.toolbarItems[identifier] as? KMToolBoxItem
- if item == nil {
- item = KMToolBoxItem.init(itemIdentifier: identifier)
- self.toolbarItems[identifier] = item
- if identifier == KMLeftControlToolbarItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolbarLeft")
- item?.titleName = "View Settings"
- item?.alternateImage = NSImage(named: "KMImageNameMainToolbarLeft")
- item?.target = self
- item?.btnTag = KMToolbarViewType.LeftPanel.rawValue
- item?.toolTip = NSLocalizedString("View Settings", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(leftPanelAction)
-
- let menuItem = NSMenuItem.init(title: item?.titleName, action: #selector(leftPanelAction), target: self)
- menuItem?.target = self
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMDocumentZoomToolbarItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolbarMinus")
- item?.titleName = "zoom"
- item?.alternateImage = NSImage(named: "KMImageNameMainToolbarMinus")
- item?.target = self
- item?.btnTag = 0
- item?.toolTip = NSLocalizedString("", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(zoomPDFViewButtonAction)
-
- let menuItem = NSMenuItem.init(title: item?.titleName, action: #selector(zoomPDFViewButtonAction), target: self)
- menuItem?.target = self
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMDocumentZoomOutToolbarItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolbarPlus")
- item?.titleName = "zoom"
- item?.alternateImage = NSImage(named: "KMImageNameMainToolbarPlus")
- item?.target = self
- item?.btnTag = 1
- // item?.toolTip = NSLocalizedString("Annotate PDF with highlight, text box and markup tools", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(zoomPDFViewButtonAction)
-
- let menuItem = NSMenuItem.init(title: item?.titleName, action: #selector(zoomPDFViewButtonAction), target: self)
- menuItem?.target = self
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMDocumentZoomViewToolbarItemIdentifier{
- item?.titleName = "Zoom"
- item?.target = self
- item?.customizeView = self.zoomView;
-
- } else if identifier == KMDocumentNextPageToolbarItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolbarForward")
- item?.titleName = "Forward"
- item?.alternateImage = NSImage(named: "KMImageNameMainToolbarForward")
- item?.target = self
- item?.btnTag = 2
- item?.toolTip = NSLocalizedString("Forward", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(zoomPDFViewButtonAction)
-
- let menuItem = NSMenuItem.init(title: item?.titleName, action: #selector(zoomPDFViewButtonAction), target: self)
- menuItem?.target = self
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMDocumentPreviousPageToolbarItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolbarBack")
- item?.titleName = "Next"
- item?.alternateImage = NSImage(named: "KMImageNameMainToolbarBack")
- item?.target = self
- item?.btnTag = 3
- item?.toolTip = NSLocalizedString("Next", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(zoomPDFViewButtonAction)
-
- let menuItem = NSMenuItem.init(title: item?.titleName, action: #selector(zoomPDFViewButtonAction), target: self)
- menuItem?.target = self
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMDocumentAnnotationToolbarItemIdentifier {
- item?.titleName = NSLocalizedString("Annotation", comment: "")
- item?.target = self
- item?.isMainTool = true
- item?.toolTip = NSLocalizedString("Add annotation with highlight, text and shape tool", comment: "")
- item?.btnTag = KMToolbarViewType.Annatiton.rawValue
- item?.btnAction = #selector(leftControllButtonAction)
-
- let menuItem = NSMenuItem.init(title: item?.titleName, action: #selector(leftControllButtonAction), target: self)
- menuItem?.target = self
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMDocumentPageToolbarItemIdentifier {
- item?.titleName = NSLocalizedString("Page Edit", comment: "")
- item?.target = self
- item?.isMainTool = true
- item?.toolTip = NSLocalizedString("PDF Page Editor: rotate, delete, paste, copy, and cut pages", comment: "")
- item?.btnTag = KMToolbarViewType.Page.rawValue
- item?.btnAction = #selector(leftControllButtonAction)
- let menuItem = NSMenuItem.init(title: item?.titleName, action: #selector(leftControllButtonAction), target: self)
- menuItem?.target = self
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMDocumentConversonToolbarItemIdentifier {
- item?.titleName = NSLocalizedString("Converter", comment: "")
- item?.target = self
- item?.isMainTool = true
- item?.toolTip = NSLocalizedString("Convert PDF to Word, Excel, PPT, RTF, CSV, HTML, Text and Image.", comment: "")
- item?.btnTag = KMToolbarViewType.Conversion.rawValue
- item?.btnAction = #selector(leftControllButtonAction)
-
- let menuItem = NSMenuItem.init(title: item?.titleName, action: #selector(leftControllButtonAction), target: self)
- menuItem?.target = self
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMDocumentScanOCRToolbarItemIdentifier {
- item?.titleName = NSLocalizedString("Scan & OCR", comment: "")
- item?.target = self
- item?.isMainTool = true
- item?.btnTag = KMToolbarViewType.ScanOCR.rawValue
- item?.toolTip = NSLocalizedString("Scan & OCR", comment: "")
- item?.btnAction = #selector(leftControllButtonAction)
- let menuItem = NSMenuItem.init(title: item?.titleName, action: #selector(leftControllButtonAction), target: self)
- menuItem?.target = self
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolEnhancedScanIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolEnhancedScan")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolEnhancedScan")
- item?.target = self
- item?.btnTag = 0
- item?.toolTip = NSLocalizedString("Enhanced Scan", comment: "")
- item?.titleName = NSLocalizedString("Enhanced Scan", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.left
- item?.btnAction = #selector(scanOCRModelSelect)
-
- } else if identifier == KMToolbarToolOCRTextIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolOCRText")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolOCRText")
- item?.target = self
- item?.btnTag = 1
- item?.toolTip = NSLocalizedString("OCR Text Recognition", comment: "")
- item?.titleName = NSLocalizedString("OCR Text Recognition", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.left
- item?.btnAction = #selector(scanOCRModelSelect)
-
- } else if identifier == KMDocumentEditToolbarItemIdentifier {
- item?.titleName = NSLocalizedString("Edit", comment: "")
- item?.target = self
- item?.isMainTool = true
- item?.btnTag = KMToolbarViewType.editPDF.rawValue
- item?.toolTip = NSLocalizedString("Edit text and image in PDF", comment: "")
- item?.btnAction = #selector(leftControllButtonAction)
-
- let menuItem = NSMenuItem.init(title: item?.titleName, action: #selector(leftControllButtonAction), target: self)
- menuItem?.target = self
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMDocumentFormToolbarItemIdentifier {
- item?.titleName = NSLocalizedString("Form", comment: "")
- item?.target = self
- item?.isMainTool = true
- item?.btnTag = KMToolbarViewType.Form.rawValue
- item?.toolTip = NSLocalizedString("Form", comment: "")
- item?.btnAction = #selector(leftControllButtonAction)
-
- let menuItem = NSMenuItem.init(title: item?.titleName, action: #selector(leftControllButtonAction), target: self)
- menuItem?.target = self
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMDocumentFillSginToolbarItemIdentifier {
- item?.titleName = NSLocalizedString("Fillsign", comment: "")
- item?.target = self
- item?.isMainTool = true
- item?.btnTag = KMToolbarViewType.FillSign.rawValue
- item?.toolTip = NSLocalizedString("Fill and sign forms or allow others to sign them", comment: "")
- item?.btnAction = #selector(leftControllButtonAction)
-
- let menuItem = NSMenuItem.init(title: item?.titleName, action: #selector(leftControllButtonAction), target: self)
- menuItem?.target = self
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMDocumentToolToolbarItemIdentifier {
- item?.titleName = NSLocalizedString("Tools", comment: "")
- item?.target = self
- item?.isMainTool = true
- item?.btnTag = KMToolbarViewType.Tool.rawValue
- item?.toolTip = NSLocalizedString("Advanced editing tools", comment: "")
- item?.btnAction = #selector(leftControllButtonAction)
-
- let menuItem = NSMenuItem.init(title: item?.titleName, action: #selector(leftControllButtonAction), target: self)
- menuItem?.target = self
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMDocumentAITranslationToolbarItemIdentifier {
- item?.image = NSImage(named: "ic_function_other_AITranslation")
- item?.titleName = "AI Translation"
- item?.alternateImage = NSImage(named: "ic_function_other_AITranslation")
- item?.target = self
- item?.toolTip = NSLocalizedString("AI Translation", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(aiTranslationButtonAction)
-
- let menuItem = NSMenuItem.init(title: item?.titleName, action: #selector(aiTranslationButtonAction), target: self)
- menuItem?.target = self
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMDocumentPrintToolbarItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolbarPrint")
- item?.titleName = "Print"
- item?.alternateImage = NSImage(named: "KMImageNameMainToolbarPrint")
- item?.target = self
- item?.toolTip = NSLocalizedString("Print", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(printPDFViewButtonAction)
-
- let menuItem = NSMenuItem.init(title: item?.titleName, action: #selector(printPDFViewButtonAction), target: self)
- menuItem?.target = self
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMDocumentShareToolbarItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolbarShare")
- item?.titleName = "Share"
- item?.alternateImage = NSImage(named: "KMImageNameMainToolbarShare")
- item?.target = self
- item?.toolTip = NSLocalizedString("Share the file with others", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(shareButtonAction)
-
- let menuItem = NSMenuItem.init(title: item?.titleName, action: nil, target: self)
- let menu = NSMenu()
- menu.addItem(withTitle: NSLocalizedString("Document", comment: ""), action: #selector(shareViaWithDocument), target: self)
- menu.addItem(withTitle: NSLocalizedString("Flattened Copy", comment: ""), action: #selector(shareViaWithFlatten), target: self)
- menu.addItem(withTitle: NSLocalizedString("Original PDF", comment: ""), action: #selector(shareViaWithOriginalPDF), target: self)
- menuItem?.submenu = menu
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMRightControlToolbarItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolbarrRight")
- item?.titleName = "right"
- item?.alternateImage = NSImage(named: "KMImageNameMainToolbarrRight")
- item?.target = self
- item?.btnTag = KMToolbarViewType.RightPanel.rawValue
- item?.toolTip = NSLocalizedString("Show/hide the right properties panel", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(rightPanelControllButtonAction)
-
- let menuItem = NSMenuItem.init(title: item?.titleName, action: #selector(rightPanelControllButtonAction), target: self)
- menuItem?.target = self
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarMoveToolModeItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolMove")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolMove")
- item?.target = self
- item?.btnTag = KMToolbarViewType.Move.rawValue
- item?.toolTip = NSLocalizedString("Scroll Tool", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(leftControllButtonAction)
-
- let menuItem = NSMenuItem.init(title: "Scroll Tool", action: #selector(leftControllButtonAction), target: self)
- menuItem?.tag = KMToolbarViewType.Move.rawValue
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarMagnifyToolModeItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolMagnify")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolMagnify")
- item?.target = self
- item?.btnTag = KMToolbarViewType.Magnify.rawValue
- item?.toolTip = NSLocalizedString("Magnify Tool", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(leftControllButtonAction)
-
- let menuItem = NSMenuItem.init(title: "Magnify Tool", action: #selector(leftControllButtonAction), target: self)
- menuItem?.tag = KMToolbarViewType.Magnify.rawValue
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarSelectToolModeItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolSelect")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolSelect")
- item?.target = self
- item?.btnTag = KMToolbarViewType.Select.rawValue
- item?.toolTip = NSLocalizedString("Content Selection", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(leftControllButtonAction)
-
- let menuItem = NSMenuItem.init(title: "Content Selection", action: #selector(leftControllButtonAction), target: self)
- menuItem?.tag = KMToolbarViewType.Select.rawValue
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarZoomToSelectionItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolSelectZoom")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolSelectZoom")
- item?.target = self
- item?.btnTag = KMToolbarViewType.SelectZoom.rawValue
- item?.toolTip = NSLocalizedString("Zoom to selected area", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(leftControllButtonAction)
-
- let menuItem = NSMenuItem.init(title: "", action: #selector(leftControllButtonAction), target: self)
- menuItem?.tag = KMToolbarViewType.SelectZoom.rawValue
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarHighlightAnnotationItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolHighlight")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolHighlight")
- item?.target = self
- item?.btnTag = CAnnotationType.highlight.rawValue
- item?.toolTip = NSLocalizedString("Highlight (⌃⌘H)", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "highlight", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = CAnnotationType.highlight.rawValue
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarUnderlineAnnotationItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolUnderline")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolUnderline")
- item?.target = self
- item?.btnTag = CAnnotationType.underline.rawValue
- item?.toolTip = NSLocalizedString("Underline (⌃⌘U)", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "underline", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = CAnnotationType.underline.rawValue
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarStrikeOutAnnotationItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolStrikeththrough")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolStrikeththrough")
- item?.target = self
- item?.btnTag = CAnnotationType.strikeOut.rawValue
- item?.toolTip = NSLocalizedString("Strikethrough (⌃⌘S)", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "strikeOut", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = CAnnotationType.strikeOut.rawValue
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarInkAnnotationItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolPen")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolPen")
- item?.target = self
- item?.btnTag = CAnnotationType.ink.rawValue
- item?.toolTip = NSLocalizedString("Draw freely as you do with a pen", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "Freehand", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = CAnnotationType.ink.rawValue
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarFreeTextAnnotationItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolFreeText")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolFreeText")
- item?.target = self
- item?.btnTag = CAnnotationType.freeText.rawValue
- item?.toolTip = NSLocalizedString("Text (⌃⌘T)", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "FreeText", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = CAnnotationType.freeText.rawValue
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarAnchoredAnnotationItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolAnchored")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolAnchored")
- item?.target = self
- item?.btnTag = CAnnotationType.anchored.rawValue
- item?.toolTip = NSLocalizedString("Sticky Note(⌃⌘N)", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "Anchored", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = CAnnotationType.anchored.rawValue
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarSquareAnnotationItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolSquare_Default")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolSquare_Default")
- item?.target = self
- item?.btnTag = CAnnotationType.square.rawValue
- item?.toolTip = NSLocalizedString("Hold shift to draw square/circle/straight arrow/line", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "Square", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = CAnnotationType.square.rawValue
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarLinkAnnotationItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolLine")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolLine")
- item?.target = self
- item?.btnTag = CAnnotationType.link.rawValue
- item?.toolTip = NSLocalizedString("Select an area or text on the page for a link to be inserted", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "Link", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = CAnnotationType.link.rawValue
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarSignSignatureAnnotationItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolSignSignature")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolSignSignature")
- item?.target = self
- item?.btnTag = CAnnotationType.signSignature.rawValue
- item?.toolTip = NSLocalizedString("Add a handwritten signature or create a signature via the trackpad", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "SignSignature", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = CAnnotationType.signSignature.rawValue
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMAnnotationStampToolbarItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolStamp")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolStamp")
- item?.target = self
- item?.btnTag = CAnnotationType.stamp.rawValue
- item?.toolTip = NSLocalizedString("Add Stamp", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "Stamp", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = CAnnotationType.stamp.rawValue
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarShowToolbarItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolShow")
- item?.selectedImage = NSImage(named: "KMImageNameMainToolHide")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolShow")
- item?.selectedBackgroundColor = NSColor.clear
- item?.target = self
- item?.toolTip = NSLocalizedString("Hide", comment: "")
- item?.titleName = NSLocalizedString("Hide", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(showPDFLayoutMode)
-
- let menuItem = NSMenuItem.init(title: "Hide", action: #selector(showPDFLayoutMode), target: self)
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarAddTextEditPDFItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolFreeText")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolFreeText")
- item?.target = self
- item?.btnTag = CAnnotationType.addText.rawValue
- item?.toolTip = NSLocalizedString("Add Text", comment: "")
- item?.titleName = NSLocalizedString("Add Text", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.left
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "Add Text", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = CAnnotationType.addText.rawValue
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarAddImageEditPDFItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolEditImage")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolEditImage")
- item?.target = self
- item?.btnTag = CAnnotationType.addImage.rawValue
- item?.toolTip = NSLocalizedString("Add Image", comment: "")
- item?.titleName = NSLocalizedString("Add Image", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.left
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "Add Image", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = CAnnotationType.addImage.rawValue
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolCropItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolbarrRight")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolbarrRight")
- item?.target = self
- item?.btnTag = KMToolbarType.crop.rawValue
- item?.toolTip = NSLocalizedString("Crop pages", comment: "")
- item?.titleName = NSLocalizedString("Crop", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.expandLeft
- item?.btnAction = #selector(cropMenuAction)
-
- let menuItem = NSMenuItem.init(title: "Crop", action: #selector(cropMenuAction), target: self)
-
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolBatesItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolsBatesNumber")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolsBatesNumber")
- item?.target = self
- item?.btnTag = KMToolbarType.bates.rawValue
- item?.toolTip = NSLocalizedString("Bates Number", comment: "")
- item?.titleName = NSLocalizedString("Bates Number", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.left
- item?.btnAction = #selector(batesMenuAction)
-
- let menuItem = NSMenuItem.init(title: "Bates Number", action: #selector(batesMenuAction), target: self)
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolHeaderFooterItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolsHeadeFooter")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolsHeadeFooter")
- item?.target = self
- item?.btnTag = KMToolbarType.headerAndFooter.rawValue
- item?.toolTip = NSLocalizedString("Header&Footer", comment: "")
- item?.titleName = NSLocalizedString("Header&Footer", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.left
- item?.btnAction = #selector(headerfooterMenuAction)
-
- let menuItem = NSMenuItem.init(title: "Header&Footer", action: #selector(headerfooterMenuAction), target: self)
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolBackgroundItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolsBackgroud")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolsBackgroud")
- item?.target = self
- item?.btnTag = KMToolbarType.background.rawValue
- item?.toolTip = NSLocalizedString("Backgroud", comment: "")
- item?.titleName = NSLocalizedString("Backgroud", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.left
- item?.btnAction = #selector(backgroundMenuAction)
-
- let menuItem = NSMenuItem.init(title: "Backgroud", action: #selector(backgroundMenuAction), target: self)
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolWatermarkItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolsWatermark")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolsWatermark")
- item?.target = self
- item?.btnTag = KMToolbarType.watermark.rawValue
- item?.toolTip = NSLocalizedString("Watermark", comment: "")
- item?.titleName = NSLocalizedString("Watermark", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.left
- item?.btnAction = #selector(watermarkMenuAction)
-
- let menuItem = NSMenuItem.init(title: "Watermark", action: #selector(watermarkMenuAction), target: self)
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolTextFieldItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolFormText")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolFormText")
- item?.target = self
- item?.btnTag = CAnnotationType.textField.rawValue
- item?.toolTip = NSLocalizedString("TextField", comment: "")
- item?.titleName = NSLocalizedString("TextField", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "TextField", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolCheckBoxItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolFormCheckbox")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolFormCheckbox")
- item?.target = self
- item?.btnTag = CAnnotationType.checkBox.rawValue
- item?.toolTip = NSLocalizedString("CheckBox", comment: "")
- item?.titleName = NSLocalizedString("CheckBox", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "CheckBox", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolRadioButtonItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolFormRadio")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolFormRadio")
- item?.target = self
- item?.btnTag = CAnnotationType.radioButton.rawValue
- item?.toolTip = NSLocalizedString("RadioButton", comment: "")
- item?.titleName = NSLocalizedString("RadioButton", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "RadioButton", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolListBoxItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolFormListBox")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolFormListBox")
- item?.target = self
- item?.btnTag = CAnnotationType.listMenu.rawValue
- item?.toolTip = NSLocalizedString("ListBox", comment: "")
- item?.titleName = NSLocalizedString("ListBox", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "ListBox", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolPullDownmenuItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolFormPulldown")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolFormPulldown")
- item?.target = self
- item?.btnTag = CAnnotationType.comboBox.rawValue
- item?.toolTip = NSLocalizedString("PullDownmenu", comment: "")
- item?.titleName = NSLocalizedString("PullDownmenu", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "PullDownmenu", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolButtonIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolFormButton")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolFormButton")
- item?.target = self
- item?.btnTag = CAnnotationType.actionButton.rawValue
- item?.toolTip = NSLocalizedString("Button", comment: "")
- item?.titleName = NSLocalizedString("Button", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "Button", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolSignBoxIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolFormSign")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolFormSign")
- item?.target = self
- item?.btnTag = CAnnotationType.signature.rawValue
- item?.toolTip = NSLocalizedString("SignBox", comment: "")
- item?.titleName = NSLocalizedString("SignBox", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "SignBox", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolFormAlignIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolFormAlignment")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolFormAlignment")
- item?.target = self
- item?.toolTip = NSLocalizedString("Alignment", comment: "")
- item?.titleName = NSLocalizedString("Alignment", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.expandLeft
- item?.btnAction = #selector(formsAlignmentAction)
-
- let menuItem = NSMenuItem.init(title: "Alignment", action: #selector(formsAlignmentAction), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolFormMoreIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolFormMore")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolFormMore")
- item?.target = self
- item?.toolTip = NSLocalizedString("More", comment: "")
- item?.titleName = NSLocalizedString("More", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.expandLeft
- item?.btnAction = #selector(formsMoreOperationAction)
-
- let menuItem = NSMenuItem.init(title: "More", action: #selector(formsMoreOperationAction), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolRedactItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolsRedact")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolsRedact")
- item?.target = self
- item?.btnTag = KMToolbarType.redact.rawValue
- item?.toolTip = NSLocalizedString("Redact", comment: "")
- item?.titleName = NSLocalizedString("Redact", comment: "")
- item?.btnAction = #selector(redactMenuAction)
-
- let menuItem = NSMenuItem.init(title: "Redact", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolCompressItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolsCompress")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolsCompress")
- item?.target = self
- item?.btnTag = KMToolbarType.compress.rawValue
- item?.toolTip = NSLocalizedString("Reduce file size or custimize the quality to make the document smaller.", comment: "")
- item?.titleName = NSLocalizedString("Compress", comment: "")
- item?.btnAction = #selector(compressMenuAction)
-
- let menuItem = NSMenuItem.init(title: "Compress", action: #selector(compressMenuAction), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolSecureItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolsSecurity")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolsSecurity")
- item?.target = self
- item?.btnTag = KMToolbarType.secure.rawValue
- item?.toolTip = NSLocalizedString("", comment: "")
- item?.titleName = NSLocalizedString("Security", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.expandLeft
- item?.btnAction = #selector(secureMenuAction)
-
- let menuItem = NSMenuItem.init(title: "Security", action: #selector(secureMenuAction), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolHookItemIdentifier {
- item?.image = NSImage(named: "KMImageNameFillSignHook")
- item?.alternateImage = NSImage(named: "KMImageNameFillSignHook")
- item?.target = self
- item?.btnTag = CAnnotationType.signTure.rawValue
- item?.toolTip = NSLocalizedString("Check", comment: "")
- item?.titleName = NSLocalizedString("Signature", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "Signature", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolForkItemIdentifier {
- item?.image = NSImage(named: "KMImageNameFillSignFork")
- item?.alternateImage = NSImage(named: "KMImageNameFillSignFork")
- item?.target = self
- item?.btnTag = CAnnotationType.signFalse.rawValue
- item?.toolTip = NSLocalizedString("X", comment: "")
- item?.titleName = NSLocalizedString("signFalse", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "signFalse", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolLineItemIdentifier {
- item?.image = NSImage(named: "KMImageNameFillSignLine")
- item?.alternateImage = NSImage(named: "KMImageNameFillSignLine")
- item?.target = self
- item?.btnTag = CAnnotationType.signLine.rawValue
- item?.toolTip = NSLocalizedString("Line", comment: "")
- item?.titleName = NSLocalizedString("Line", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "Line", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolDotItemIdentifier {
- item?.image = NSImage(named: "KMImageNameFillSignDot")
- item?.alternateImage = NSImage(named: "KMImageNameFillSignDot")
- item?.target = self
- item?.btnTag = CAnnotationType.signDot.rawValue
- item?.toolTip = NSLocalizedString("Dot", comment: "")
- item?.titleName = NSLocalizedString("Dot", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "Dot", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolRectangleIdentifier {
- item?.image = NSImage(named: "KMImageNameFillSignRectangle")
- item?.alternateImage = NSImage(named: "KMImageNameFillSignRectangle")
- item?.target = self
- item?.btnTag = CAnnotationType.signCircle.rawValue
- item?.toolTip = NSLocalizedString("Rectangle", comment: "")
- item?.titleName = NSLocalizedString("Rectangle", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "Rectangle", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolTextIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolFreeText")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolFreeText")
- item?.target = self
- item?.btnTag = CAnnotationType.signText.rawValue
- item?.toolTip = NSLocalizedString("Add a handwritten signature or create a signature via the trackpad", comment: "")
- item?.titleName = NSLocalizedString("signText", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "signText", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolDateIdentifier {
- item?.image = NSImage(named: "KMImageNameFillSignDate")
- item?.alternateImage = NSImage(named: "KMImageNameFillSignDate")
- item?.target = self
- item?.btnTag = CAnnotationType.signDate.rawValue
- item?.toolTip = NSLocalizedString("Date", comment: "")
- item?.titleName = NSLocalizedString("Date", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "Date", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if (identifier == KMToolbarFillSignSignatureIdentifier) {
- item?.image = NSImage(named: "KMImageNameMainToolSignSignature")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolSignSignature")
- item?.target = self
- item?.btnTag = CAnnotationType.signSignature.rawValue
- item?.toolTip = NSLocalizedString("Add a handwritten signature or create a signature via the trackpad", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.only
- item?.btnAction = #selector(changeAnnotationMode)
-
- let menuItem = NSMenuItem.init(title: "SignSignature", action: #selector(changeAnnotationMode), target: self)
- menuItem?.tag = CAnnotationType.signSignature.rawValue
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarConversionWordItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolConverterWord")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolConverterWord")
- item?.target = self
- item?.btnTag = KMToolbarType.word.rawValue
- item?.toolTip = NSLocalizedString("Convert PDF to editable Word documents.", comment: "")
- item?.titleName = NSLocalizedString("To Word", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.left
- item?.btnAction = #selector(conversionMenuItemAction)
-
- let menuItem = NSMenuItem.init(title: "To Word", action: #selector(conversionMenuItemAction), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarConversionExcelItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolConverterExcel")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolConverterExcel")
- item?.target = self
- item?.btnTag = KMToolbarType.excel.rawValue
- item?.toolTip = NSLocalizedString("Extract data from PDF to Excel", comment: "")
- item?.titleName = NSLocalizedString("To Excel", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.left
- item?.btnAction = #selector(conversionMenuItemAction)
-
- let menuItem = NSMenuItem.init(title: "To Excel", action: #selector(conversionMenuItemAction), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarConversionPPTItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolConverterPPT")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolConverterPPT")
- item?.target = self
- item?.btnTag = KMToolbarType.ppt.rawValue
- item?.toolTip = NSLocalizedString("Convert PDF documents to PPT while retaining formatting", comment: "")
- item?.titleName = NSLocalizedString("To PPT", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.left
- item?.btnAction = #selector(conversionMenuItemAction)
-
- let menuItem = NSMenuItem.init(title: "To PPT", action: #selector(conversionMenuItemAction), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarConversionRTFItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolConverterRTF")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolConverterRTF")
- item?.target = self
- item?.btnTag = KMToolbarType.rtf.rawValue
- item?.toolTip = NSLocalizedString("Convert PDF to RTF that can be opened in almost any word processor", comment: "")
- item?.titleName = NSLocalizedString("To RTF", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.left
- item?.btnAction = #selector(conversionMenuItemAction)
-
- let menuItem = NSMenuItem.init(title: "To RTF", action: #selector(conversionMenuItemAction), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarConversionCSVItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolConverterCSV")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolConverterCSV")
- item?.target = self
- item?.btnTag = KMToolbarType.csv.rawValue
- item?.toolTip = NSLocalizedString("To CSV", comment: "")
- item?.titleName = NSLocalizedString("To CSV", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.left
- item?.btnAction = #selector(conversionMenuItemAction)
-
- let menuItem = NSMenuItem.init(title: "To CSV", action: #selector(conversionMenuItemAction), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarConversionHTMLItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolConverterHTML")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolConverterHTML")
- item?.target = self
- item?.btnTag = KMToolbarType.html.rawValue
- item?.toolTip = NSLocalizedString("To HTML", comment: "")
- item?.titleName = NSLocalizedString("To HTML", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.left
- item?.btnAction = #selector(conversionMenuItemAction)
-
- let menuItem = NSMenuItem.init(title: "To HTML", action: #selector(conversionMenuItemAction), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarConversionTextItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolConverterText")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolConverterText")
- item?.target = self
- item?.btnTag = KMToolbarType.conversion_text.rawValue
- item?.toolTip = NSLocalizedString("To Text", comment: "")
- item?.titleName = NSLocalizedString("To Text", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.left
- item?.btnAction = #selector(conversionMenuItemAction)
-
- let menuItem = NSMenuItem.init(title: "To Text", action: #selector(conversionMenuItemAction), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarConversionImageItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolConverterImage")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolConverterImage")
- item?.target = self
- item?.btnTag = KMToolbarType.conversion_image.rawValue
- item?.toolTip = NSLocalizedString("Convert each page in a PDF to JPEG, JPG, PNG, GIF and other formats", comment: "")
- item?.titleName = NSLocalizedString("To Image", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.left
- item?.btnAction = #selector(conversionMenuItemAction)
-
- let menuItem = NSMenuItem.init(title: "To Image", action: #selector(conversionMenuItemAction), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- } else if identifier == KMToolbarToolMergeItemIdentifier {
- item?.image = NSImage(named: "KMImageNameMainToolsMerge")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolsMerge")
- item?.target = self
- item?.btnTag = KMToolbarType.merge.rawValue
- item?.toolTip = NSLocalizedString("Combine multiple files into a new PDF.", comment: "")
- item?.titleName = NSLocalizedString("Merge", comment: "")
- item?.boxImagePosition = KMToolBoxImagePosition.left
- item?.btnAction = #selector(mergeMenuItemAction)
-
- let menuItem = NSMenuItem.init(title: "Merge", action: #selector(mergeMenuItemAction), target: self)
- menuItem?.tag = item!.btnTag
- item?.menuFormRepresentation = menuItem
- }
- }
- return item
- }
-
- func validateToolbarItem(_ item: NSToolbarItem) -> Bool {
- return true
- }
-
- @objc func listViewAnnotationTypeChangeNotification(sender: Notification?) {
- // if let notiName = sender?.name, notiName == NSNotification.Name.CPDFListViewAnnotationTypeChange, self.ignoreCurrentAnnotationTypeChange {
-
- // }
- if (self.ignoreCurrentAnnotationTypeChange) {
- // 忽略后重置 这个属性是基于单次添加,所以使用后会重置
- // self.ignoreCurrentAnnotationTypeChange = false
- return
- }
-
- let annotationType : CAnnotationType = pdfView.annotationType
- if annotationType == .square || annotationType == .circle || annotationType == .arrow || annotationType == .line{
- UserDefaults.standard.set(pdfView.annotationType.rawValue, forKey: KMToolBarToolPDFShapeStyle)
- UserDefaults.standard.synchronize()
- }
- for item in self.toolbar.items {
- if self.toolbarType == .Annatiton || self.toolbarType == .Move || self.toolbarType == .Magnify ||
- self.toolbarType == .Select || self.toolbarType == .SelectZoom {
- item.isSelected = false
- if item.itemIdentifier == KMDocumentAnnotationToolbarItemIdentifier {
- item.isSelected = true
- } else if item.itemIdentifier == KMToolbarHighlightAnnotationItemIdentifier {
- if annotationType == .highlight {
- item.isSelected = true
- }
- } else if item.itemIdentifier == KMToolbarUnderlineAnnotationItemIdentifier {
- if annotationType == .underline {
- item.isSelected = true
- }
- } else if item.itemIdentifier == KMToolbarStrikeOutAnnotationItemIdentifier {
- if annotationType == .strikeOut {
- item.isSelected = true
- }
- } else if item.itemIdentifier == KMToolbarInkAnnotationItemIdentifier {
- if annotationType == .ink || annotationType == .eraser {
- item.isSelected = true
- }
- } else if item.itemIdentifier == KMToolbarFreeTextAnnotationItemIdentifier {
- if annotationType == .freeText {
- item.isSelected = true
- }
- } else if item.itemIdentifier == KMToolbarAnchoredAnnotationItemIdentifier {
- if annotationType == .anchored {
- item.isSelected = true
- }
- } else if item.itemIdentifier == KMToolbarSquareAnnotationItemIdentifier {
- if annotationType == .square || annotationType == .circle || annotationType == .arrow || annotationType == .line {
- item.isSelected = true
- }
- } else if item.itemIdentifier == KMToolbarLinkAnnotationItemIdentifier {
- if annotationType == .link {
- item.isSelected = true
- }
- } else if item.itemIdentifier == KMAnnotationStampToolbarItemIdentifier {
- if annotationType == .stamp {
- item.isSelected = true
- }
- } else if item.itemIdentifier == KMToolbarSignSignatureAnnotationItemIdentifier {
- if annotationType == .signSignature {
- item.isSelected = true
- }
- } else if pdfView.toolMode == .moveToolMode {
- if item.itemIdentifier == KMToolbarMoveToolModeItemIdentifier {
- item.isSelected = true
- }
- } else if pdfView.toolMode == .magnifyToolMode {
- if item.itemIdentifier == KMToolbarMagnifyToolModeItemIdentifier {
- item.isSelected = true
- }
- } else if pdfView.toolMode == .selectToolMode {
- if item.itemIdentifier == KMToolbarSelectToolModeItemIdentifier {
- item.isSelected = true
- }
- } else if pdfView.toolMode == .selectZoomToolMode {
- if item.itemIdentifier == KMToolbarZoomToSelectionItemIdentifier {
- item.isSelected = true
- }
- }
-
- if (item.itemIdentifier == KMToolbarShowToolbarItemIdentifier) {
- item.isSelected = !self.isShowAllAnnotations
- }
- } else if self.toolbarType == .FillSign {
- item.isSelected = false
- if pdfView.toolMode == .selfSignMode {
- if item.itemIdentifier == KMToolbarToolHookItemIdentifier {
- if annotationType == .signTure {
- item.isSelected = true
- }
- } else if item.itemIdentifier == KMToolbarToolForkItemIdentifier {
- if annotationType == .signFalse {
- item.isSelected = true
- }
- } else if item.itemIdentifier == KMToolbarToolLineItemIdentifier {
- if annotationType == .signLine {
- item.isSelected = true
- }
- } else if item.itemIdentifier == KMToolbarToolDotItemIdentifier {
- if annotationType == .signDot {
- item.isSelected = true
- }
- } else if item.itemIdentifier == KMToolbarToolRectangleIdentifier {
- if annotationType == .signCircle {
- item.isSelected = true
- }
- } else if item.itemIdentifier == KMToolbarToolDateIdentifier {
- if annotationType == .signDate {
- item.isSelected = true
- }
- } else if item.itemIdentifier == KMToolbarToolTextIdentifier {
- if annotationType == .signText {
- item.isSelected = true
- }
- } else if (item.itemIdentifier == KMToolbarFillSignSignatureIdentifier) {
- if (annotationType == .signSignature) {
- item.isSelected = true
- }
- }
- }
- }
- }
- }
- }
|