123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503 |
- //
- // 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 changePDFViewGotoBackAction()
- @objc optional func changePDFViewGoToForwardAction()
- @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, shareAction toolbarItem: KMToolBoxItem)
- @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.km_init(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 VERSION_DMG
- if await (KMLightMemberManager.manager.canUseAdvanced() == false) {
- let _ = KMComparativeTableViewController.show(window: self.view.window!)
- return
- }
- #endif
- 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?.changePDFViewGotoBackAction?()
- } else if sender.tag == 3 {
- self.delegate?.changePDFViewGoToForwardAction?()
- }
- }
-
- @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)
-
- self.delegate?.toolbarViewController?(self, shareAction: sender.clickObject as! KMToolBoxItem)
- }
-
- @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 {
- KMPrint("按下 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, KMDocumentPreviousPageToolbarItemIdentifier, KMDocumentNextPageToolbarItemIdentifier]
- }
- 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: "KMImageNameMainToolsCrop")
- item?.alternateImage = NSImage(named: "KMImageNameMainToolsCrop")
- 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
- }
- }
- }
- }
- }
- }
- }
|