123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680 |
- //
- // KMConvertBaseWindowController.swift
- // PDF Office
- //
- // Created by tangchao on 2022/12/5.
- //
- import Cocoa
- import PDFKit
- extension NSPanel {
- public func open(_ window: NSWindow, panel:((NSOpenPanel)->Void)?, completion:@escaping ((NSApplication.ModalResponse, [URL]?)->Void)) {
- let openPanel = NSOpenPanel()
- if (panel != nil) {
- panel!(openPanel)
- } else {
- openPanel.prompt = ""
- openPanel.canChooseFiles = true //是否可以选择文件
- }
-
- openPanel.beginSheetModal(for: window, completionHandler: { result in
- if result != .OK {
- completion(result, nil)
- } else {
- completion(result, openPanel.urls)
- }
- })
- }
-
- public class func savePanel(_ window: NSWindow, panel:((NSSavePanel)->Void)?, completion:@escaping ((NSApplication.ModalResponse, URL?)->Void)) {
- let savePanel = NSSavePanel()
- if (panel != nil) {
- panel!(savePanel)
- } else {
- savePanel.prompt = ""
- }
-
- savePanel.beginSheetModal(for: window, completionHandler: { result in
- if result != .OK {
- completion(result, nil)
- } else {
- completion(result, savePanel.url)
- }
- })
- }
-
- public class func savePanel(_ window: NSWindow, _ openAccessoryView: Bool, panel:((NSSavePanel)->Void)?, completion:@escaping ((NSApplication.ModalResponse, URL?, Bool)->Void)) {
- let savePanel = NSSavePanel()
- if (panel != nil) {
- panel!(savePanel)
- } else {
- savePanel.prompt = ""
- }
-
- if (openAccessoryView) {
- savePanel.accessoryView = NSButton(checkboxWithTitle: NSLocalizedString("Open the document after saving", comment: ""), target: nil, action: nil);
- }
-
- savePanel.beginSheetModal(for: window, completionHandler: { result in
- if result != .OK {
- completion(result, nil, false)
- } else {
- if (!openAccessoryView) {
- completion(result, savePanel.url, false)
- return
- }
-
- if ((savePanel.accessoryView as! NSButton).state == .on) {
- completion(result, savePanel.url, true)
- } else {
- completion(result, savePanel.url, false)
- }
- }
- })
- }
- }
- let kKMConvertLanugageSelectedIndex: String = "KMConvertLanugageSelectedIndex"
- typealias KMConvertSettingViewPageRangeDidInputFinishCallback = (_ pageRangeString: String) -> ()
- typealias KMConvertSettingViewLanugageDidSelectedCallback = (_ index: Int) -> ()
- class KMConvertSettingView: NSView {
- private var myCurrentLanguage: String!
- var currentLanguage: String {
- get {
- return myCurrentLanguage
- }
- set {
- myCurrentLanguage = newValue
-
- let index = UserDefaults.standard.string(forKey: kKMConvertLanugageSelectedIndex)
- if (index != nil && !index!.isEmpty) {
- ocrLanuguageIndex = Int(index!)!
- return
- }
- if (newValue.hasPrefix("zh-Hans")) {
- ocrLanuguageIndex = 0
- } else if (newValue.hasPrefix("en")) {
- ocrLanuguageIndex = 2
- } else if (newValue.hasPrefix("zh-Hant")) {
- ocrLanuguageIndex = 1
- } else if (newValue.hasPrefix("fr")) {
- ocrLanuguageIndex = 3
- } else if (newValue.hasPrefix("de")) {
- ocrLanuguageIndex = 4
- } else if (newValue.hasPrefix("ht")) { /// 海地克里奥尔语 Haitian
- ocrLanuguageIndex = 5
- } else if (newValue.hasPrefix("ja")) {
- ocrLanuguageIndex = 6
- } else if (newValue.hasPrefix("ko")) {
- ocrLanuguageIndex = 7
- } else if (newValue.hasPrefix("la")) { /// 拉丁语 Latin
- ocrLanuguageIndex = 8
- } else {
- ocrLanuguageIndex = 2
- }
- }
- }
-
- var ocrLanuguageIndex: Int = 3
-
- var pageRangeSelectedIndex: Int = 0
- var pageRangeDidInputFinishCallback: KMConvertSettingViewPageRangeDidInputFinishCallback!
- var lanugageDidSelected: KMConvertSettingViewLanugageDidSelectedCallback!
-
- var ocrItemView: KMConvertOCRSettingItemView!
- var pageRangeItemView: KMConvertPageRangeSettingItemView!
- func getPageRangeString() -> String {
- return ""
- }
- }
- typealias KMConvertBaseWindowControllerItemClick = (Int) -> ()
- class KMConvertBaseWindowController: NSWindowController {
-
- @IBOutlet weak var titleLabel: NSTextField!
-
- @IBOutlet weak var leftBox: NSBox!
- @IBOutlet weak var prePDFView: KMCustomPDFView!
- @IBOutlet weak var numberBox: NSView!
- @IBOutlet weak var numberTextField: NSTextField!
- @IBOutlet weak var perLabel: NSTextField!
- @IBOutlet weak var totalNumberLabel: NSTextField!
- @IBOutlet weak var backBox: NSBox!
- @IBOutlet weak var nextBox: NSBox!
-
- @IBOutlet weak var rightScrollView: NSScrollView!
-
- @IBOutlet weak var batchButton: NSButton!
- @IBOutlet weak var canelBox: NSBox!
- @IBOutlet weak var convertBox: NSBox!
- var canelButtonVC: KMDesignButton!
- var convertButtonVC: KMDesignButton!
- var backButtonVC: KMDesignButton!
- var nextButtonVC: KMDesignButton!
- var itemClick: KMConvertBaseWindowControllerItemClick!
-
- var documentModel: KMDocumentModel!
-
- var currentPageIndex: Int = 1
- var pageRangeString: String = ""
- var settingView: KMConvertSettingView!
-
- private var maskView: NSButton!
- private var indicator: NSProgressIndicator!
-
- var subType: Int = 0
-
- var fileExtension: String {
- get {
- return ""
- }
- }
-
- var progressController: SKProgressController?
- var convert: KMPDFConvert?
-
- override func awakeFromNib() {
- super.awakeFromNib()
- DispatchQueue.main.async {
- self.window?.makeFirstResponder(nil)
- }
- }
-
- override func windowDidLoad() {
- super.windowDidLoad()
- self.window?.appearance = NSAppearance(named: .aqua)
-
- canelButtonVC = KMDesignButton.init(withType: .Text)
- convertButtonVC = KMDesignButton.init(withType: .Text)
- backButtonVC = KMDesignButton.init(withType: .Image)
- nextButtonVC = KMDesignButton.init(withType: .Image)
-
- if documentModel != nil {
- self.prePDFView.document = CPDFDocument(url: documentModel.documentURL)
- if (documentModel.owerPassword.isEmpty == false) {
- self.prePDFView.document.unlock(withPassword: documentModel.owerPassword)
- } else if (documentModel.password.isEmpty == false) {
- self.prePDFView.document.unlock(withPassword: documentModel.password)
- }
-
- let number: Int = Int(prePDFView.document!.pageCount)
- let string = "\(number)"
- totalNumberLabel.stringValue = string
- }
- if (self.prePDFView.documentView() != nil) {
- self.prePDFView.documentView().enclosingScrollView?.hasVerticalScroller = false
- self.prePDFView.documentView().enclosingScrollView?.hasHorizontalScroller = false
- }
-
- self.prePDFView.setDisplay(.singlePage)
- self.prePDFView.layoutDocumentView()
- self.prePDFView.autoScales = true
- self.prePDFView.delegate = self
-
- backBox.fillColor = .clear
- backBox.contentView = backButtonVC.view
- backButtonVC.target = self
- backButtonVC.action = #selector(backButtonAction)
- backButtonVC.image = NSImage(named: "KMImageNameLeftButtonImage")!
- backButtonVC.image_disabled = NSImage(named: "KMImageNameLeftButtonImageDis")!
- backButtonVC.pagination()
-
- numberBox.wantsLayer = true
- self.numberBox.layer?.backgroundColor = NSColor.white.cgColor
- numberBox.layer?.borderWidth = 1
- numberBox.layer?.cornerRadius = 4
- numberTextField.focusRingType = .none
- numberTextField.delegate = self
- self.numberTextField.isBordered = false
-
- nextBox.fillColor = .clear
- nextBox.contentView = nextButtonVC.view
- nextButtonVC.target = self
- nextButtonVC.action = #selector(nextButtonAction)
- nextButtonVC.image = NSImage(named: "KMImageNameRightButtonImage")!
- nextButtonVC.image_disabled = NSImage(named: "KMImageNameRightButtonImageDis")!
- nextButtonVC.pagination()
- batchButton.title = NSLocalizedString("Batch", comment: "")
- batchButton.isBordered = false
- batchButton.wantsLayer = true
- batchButton.layer?.borderWidth = 1
- batchButton.layer?.cornerRadius = 4
- batchButton.target = self
- batchButton.action = #selector(batchButtonAction)
- batchButton.isHidden = true
-
- canelBox.fillColor = .clear
- canelBox.contentView = canelButtonVC.view
- canelButtonVC.target = self
- canelButtonVC.action = #selector(cancelButtonAction)
- canelButtonVC.stringValue = NSLocalizedString("Cancel", comment: "")
- canelButtonVC.button(type: .Sec, size: .m)
-
- convertBox.fillColor = .clear
- convertBox.contentView = convertButtonVC.view
- convertButtonVC.target = self
- convertButtonVC.action = #selector(convertButtonAction)
- convertButtonVC.stringValue = NSLocalizedString("Convert", comment: "")
- convertButtonVC.button(type: .Cta, size: .m)
-
- self.rightScrollView.hasVerticalScroller = false
- self.rightScrollView.hasHorizontalScroller = false
-
- self.initUIProperty()
- }
-
- private func initUIProperty() {
- self.titleLabel.textColor = NSColor.titleColor()
- self.titleLabel.font = .SFProTextRegular(16)
-
- self.leftBox.fillColor = NSColor(hex: "#F7F8FA")
- self.prePDFView.backgroundColor = NSColor(hex: "#E6E7EB")
- self.numberBox.layer?.borderColor = NSColor(hex: "#DFE1E5").cgColor
- self.perLabel.textColor = NSColor.titleColor()
- self.perLabel.font = .SFProTextRegular(12)
- self.totalNumberLabel.textColor = NSColor.titleColor()
- self.totalNumberLabel.font = .SFProTextRegular(12)
-
- self.batchButton.setTitleColor(NSColor.buttonTitleColor())
- self.batchButton.layer?.borderColor = NSColor.buttonBorderColor().cgColor
- self.batchButton.font = .SFProTextRegular(14)
- }
-
- @objc func backButtonAction() {
- if prePDFView.canGoToPreviousPage() {
- currentPageIndex -= 1
- prePDFView.goToPreviousPage(nil)
-
- let currentIndex: Int = Int((prePDFView.document?.index(for: prePDFView.currentPage()!))!)
- numberTextField.stringValue = "\(currentIndex+1)"
- }
- }
-
- @objc func nextButtonAction() {
- if prePDFView.canGoToNextPage() {
- currentPageIndex += 1
- prePDFView.goToNextPage(nil)
-
- let currentIndex: Int = Int((prePDFView.document?.index(for: prePDFView.currentPage()!))!)
- numberTextField.stringValue = "\(currentIndex+1)"
- }
- }
-
- @objc func batchButtonAction() {
- guard let callback = itemClick else {
- return
- }
-
- callback(1)
- }
-
- @objc func cancelButtonAction() {
- guard let callback = itemClick else {
- return
- }
-
- callback(2)
- }
-
- @objc func convertButtonAction() {
- self.window?.makeFirstResponder(nil)
-
- var pages: [Int] = []
- if self.settingView.pageRangeSelectedIndex == 0 {
- for i in 0 ... self.prePDFView.document!.pageCount-1 {
- pages.append(Int(i)+1)
- }
- } else if self.settingView.pageRangeSelectedIndex == 1 { /// 当前页面
- if self.currentPageIndex <= self.prePDFView.document!.pageCount {
- pages.append(self.currentPageIndex)
- }
- } else if self.settingView.pageRangeSelectedIndex == 2 { /// 奇数
- for i in 0 ... self.prePDFView.document!.pageCount-1 {
- if i % 2 == 0 {
- pages.append(Int(i)+1)
- }
- }
- } else if self.settingView.pageRangeSelectedIndex == 3 { /// 偶数
- for i in 0 ... self.prePDFView.document!.pageCount-1 {
- if i % 2 == 1 {
- pages.append(Int(i)+1)
- }
- }
- } else if self.settingView.pageRangeSelectedIndex == 4 { /// 自定义
- let array = self.findSelectPage(pageRangeString: self.settingView.getPageRangeString())
- if array.count == 0 {
- let alert = NSAlert()
- alert.alertStyle = .warning
- alert.messageText = NSLocalizedString("Invalid page range or the page number is out of range. Please try again.", comment: "")
- alert.runModal()
- return
- } else {
- for i in 0 ..< array.count {
- if i <= self.documentModel.document.pageCount {
- pages.append(array[i])
- }
- }
- }
- }
-
- NSPanel.savePanel(self.window!) { panel in
- let name = self.prePDFView.document.documentURL.deletingPathExtension().lastPathComponent
- panel.nameFieldStringValue = name
- panel.allowedFileTypes = [self.fileExtension]
- } completion: { response, url in
- if (response == .cancel) {
- return
- }
- let outputFolderPath = url!.deletingLastPathComponent().path
- let filePath = self.getConvertFileSavePath()
- if (FileManager.default.fileExists(atPath: filePath)) {
- try?FileManager.default.removeItem(atPath: filePath)
- }
- if ((self.prePDFView.document?.writeDecrypt(to: URL(fileURLWithPath: filePath)))!) {
-
- }
- let convert = KMPDFConvert()
- self.convert = convert
- convert.outputFolderPath = outputFolderPath
- convert.filePath = filePath
- convert.pages = pages
- var fileName = url!.deletingPathExtension().lastPathComponent
- if (fileName.isEmpty) {
- fileName = NSLocalizedString("Untitled", comment: "")
- }
- convert.outputFileName = fileName
- self.convertModelAppendParams(convert: convert)
-
- DispatchQueue.main.async {
- self.showProgressWindow()
- self.progressController?.maxValue = Double(convert.pages.count)
- }
-
- DispatchQueue.global().async {
- KMPDFConvertManager.defaultManager.convert(convert: convert, progress: { index in
- DispatchQueue.main.async {
- self.progressController?.increment(by: 1.0)
- }
- }) { [unowned self] finished, error in
- self.hiddenProgressWindow()
-
- // 清除临时文件
- if (FileManager.default.fileExists(atPath: filePath)) {
- try?FileManager.default.removeItem(atPath: filePath)
- }
- if finished {
- cancelButtonAction()
- if FileManager.default.fileExists(atPath: convert.outputFilePath) {
- NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: convert.outputFilePath)])
- }
- } else {
- var errorString = ""
- let myError: NSError? = error as? NSError
- if myError?.code == 1 {
- errorString = NSLocalizedString("Password required or incorrect password. Please re-enter your password and try again", comment: "")
- } else if myError?.code == 2 {
- errorString = NSLocalizedString("The license doesn't allow the permission", comment: "")
- } else if myError?.code == 3 {
- errorString = NSLocalizedString("Malloc failure", comment: "")
- } else if myError?.code == 4 {
- errorString = NSLocalizedString("Unknown error in processing conversion. Please try again later", comment: "")
- } else if myError?.code == 5 {
- errorString = NSLocalizedString("Unknown error in processing PDF. Please try again later", comment: "")
- } else if myError?.code == 6 {
- errorString = NSLocalizedString("File not found or could not be opened. Check if your file exists or choose another file to convert", comment: "")
- } else if myError?.code == 7 {
- errorString = NSLocalizedString("File not in PDF format or corruptead. Change a PDF file and try again", comment: "")
- } else if myError?.code == 8 {
- errorString = NSLocalizedString("Unsupported security scheme", comment: "")
- } else if myError?.code == 9 {
- errorString = NSLocalizedString("Page not found or content error", comment: "")
- } else {
- errorString = NSLocalizedString("Table not found", comment: "")
- }
-
- let alert = NSAlert()
- alert.alertStyle = .critical
- alert.messageText = NSLocalizedString("Conversion Failed", comment: "")
- alert.informativeText = errorString
- alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
- alert.runModal()
- }
- }
- }
-
- }
- }
-
- func convertModelAppendParams(convert: KMPDFConvert) -> () {
-
- }
-
- func getConvertFileSavePath() -> String {
- var path = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.applicationSupportDirectory, FileManager.SearchPathDomainMask.userDomainMask, true).last
- path?.append("/")
- path?.append(Bundle.main.bundleIdentifier!)
- path?.append("/")
- path?.append("convert.pdf")
-
- return path!
- }
-
- func isValidPagesString(pagesString: String)-> Bool {
- var valid = false
- for ch in pagesString {
- if ch != "0" && ch != "1" && ch != "2" && ch != "3" && ch != "4" && ch != "5" && ch != "6" && ch != "7" && ch != "8" && ch != "9" && ch != "," && ch != "-" {
- valid = false
- break
- } else {
- valid = true
- }
- }
-
- return valid
- }
-
- func findSelectPage(pageRangeString: String) -> ([Int]) {
- if !isValidPagesString(pagesString: pageRangeString) {
- return []
- }
-
- var result: [Int] = []
- let array = pageRangeString.components(separatedBy: ",")
- for string in array {
- if string.isEmpty {
- return []
- } else {
- let pages = string .components(separatedBy: "-")
- if pages.count > 2 {
- return []
- } else if pages.count == 1 {
- let page = pages[0]
- if page.isEmpty || Int(page)! > documentModel.document.pageCount || Int(page)! == 0 {
- return []
- } else {
- var hasSame: Bool = false
- for i in result {
- if i == Int(page)! {
- hasSame = true
- return []
- }
- }
- if !hasSame {
- result.append(Int(page)!)
- }
- }
- } else if pages.count == 2 {
- let page1 = pages[0]
- let page2 = pages[1]
- if page1.isEmpty || page2.isEmpty || Int(page1)! >= Int(page2)! || Int(page2)! > documentModel.document.pageCount || Int(page1)! == 0 {
- return []
- } else {
- var hasSame: Bool = false
- for i in Int(page1)! ... Int(page2)! {
- for j in result {
- if j == i {
- hasSame = true
- return []
- }
- }
- }
- if !hasSame {
- for i in Int(page1)! ... Int(page2)! {
- result.append(i)
- }
- }
- }
- }
- }
- }
-
- return result
- }
-
- /// 开始加载loading
- func beginLoading() {
- DispatchQueue.main.async { [self] in
- self.maskView = NSButton()
- self.maskView.isBordered = false
- self.maskView.title = ""
- self.maskView.wantsLayer = true
- self.maskView.layer?.backgroundColor = NSColor(white: 1, alpha: 0.3 ).cgColor
- self.maskView.target = self
- self.maskView.action = #selector(maskViewClick)
- self.maskView.frame = (self.window?.contentView!.bounds)!
- self.maskView.autoresizingMask = NSView.AutoresizingMask(rawValue: 18)
- self.window?.contentView?.addSubview(self.maskView)
-
- self.indicator = NSProgressIndicator()
- self.indicator.style = .spinning
- self.indicator.controlSize = .regular
- self.indicator.isIndeterminate = true
- self.window?.contentView?.addSubview(self.indicator)
- let indicatorSize: CGFloat = 32
- self.indicator.frame = NSMakeRect(0.5*(NSWidth((self.window?.contentView!.frame)!)-indicatorSize), 0.5*(NSHeight((self.window?.contentView!.frame)!)-indicatorSize), indicatorSize, indicatorSize)
- self.maskView.autoresizingMask = NSView.AutoresizingMask(rawValue: 45)
-
- self.indicator.startAnimation(nil)
- }
- }
-
- /// 结束加载loading
- func endLoading() {
- DispatchQueue.main.async {
- self.indicator.stopAnimation(nil)
-
- self.indicator.removeFromSuperview()
- self.indicator = nil
-
- self.maskView.removeFromSuperview()
- self.maskView = nil
- }
- }
-
- @objc func maskViewClick() {
-
- }
-
- // MARK: Progress
- func showProgressWindow() {
- let progress = SKProgressController()
- progress.message = NSLocalizedString("Converting...", comment: "")
- progress.window?.backgroundColor = NSColor(hex: "#36383B")
- progress.window?.contentView?.wantsLayer = true
- progress.window?.contentView?.layer?.backgroundColor = NSColor(hex: "#36383B").cgColor
- progress.progressField.textColor = NSColor.white
-
- progress.closeBlock = { [weak self] in
- if (self!.convert != nil) {
- KMPDFConvertManager.defaultManager.cancel(convert: self!.convert!)
- }
- }
-
- self.progressController = progress
- self.window?.beginSheet(progress.window!)
- }
-
- func hiddenProgressWindow() {
- if (self.progressController != nil) {
- self.window?.endSheet((self.progressController?.window)!)
- self.progressController = nil
- }
- }
-
- func getCurrentLanguage() -> String {
- // return Bundle.main.preferredLocalizations.first!
- let array: [String] = UserDefaults.standard.object(forKey: "AppleLanguages") as! [String]
- return array.first!
- }
-
- /// 存储用户的选择的语言
- func saveLanugageSelectedIndex(index: Int) {
- UserDefaults.standard.setValue("\(index)", forKey: kKMConvertLanugageSelectedIndex)
- UserDefaults.standard.synchronize()
- }
- }
- extension KMConvertBaseWindowController: NSTextFieldDelegate {
- func controlTextDidChange(_ obj: Notification) {
- if numberTextField.isEqual(to: obj.object) {
- let textField: NSTextField = obj.object as! NSTextField
- var value: String = ""
- for ch in textField.stringValue {
- if ch != "0" && ch != "1" && ch != "2" && ch != "3" && ch != "4" && ch != "5" && ch != "6" && ch != "7" && ch != "8" && ch != "9" {
- } else {
- if value.isEmpty && ch == "0" {
-
- } else {
- value.append(ch)
- }
- }
- }
-
- if value.isEmpty {
- value.append("1")
- } else {
- if Int(value)! <= 0 {
- value = "1"
- } else if Int(value)! > self.prePDFView.document!.pageCount {
- let number: Int = Int(self.prePDFView.document!.pageCount)
- value = "\(number)"
- }
- }
-
- numberTextField.stringValue = value
- }
- }
-
- func controlTextDidEndEditing(_ obj: Notification) {
- if numberTextField.isEqual(to: obj.object) {
- if (numberTextField.stringValue.isEmpty) {
- numberTextField.stringValue = "1"
- self.prePDFView.go(toPageIndex: 0, animated: false)
- self.currentPageIndex = 1
- return
- }
- let number: Int = Int(numberTextField.stringValue)!
- if number > 0 && number <= prePDFView.document!.pageCount {
- guard let page = prePDFView.document?.page(at: UInt(number-1)) else {
- return
- }
- prePDFView.go(to: page)
- currentPageIndex = number
- }
- }
- }
- }
- extension KMConvertBaseWindowController: CPDFViewDelegate {
- func pdfViewCurrentPageDidChanged(_ pdfView: CPDFView!) {
- let currentIndex = pdfView.currentPageIndex
- currentPageIndex = currentIndex + 1
- numberTextField.stringValue = "\(currentIndex+1)"
- }
- }
|