KMPDFViewManager.swift 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // KMPDFViewManager.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by Niehaoyu on 2024/10/22.
  6. //
  7. import Foundation
  8. class KMPDFViewManager: NSObject {
  9. var viewToolsType: KMPDFViewToolsType = .Select //ToolsView类型
  10. var toolMode: KMPDFToolsMode = .None //一级工具栏
  11. var subToolMode: KMPDFSubToolMode = .None //二级工具栏
  12. //侧边栏样式
  13. var pdfSideBarType: KMPDFSidebarType = .none {
  14. didSet {
  15. UserDefaults.standard.setValue(pdfSideBarType.rawValue, forKey: "KMPDFSidebarTypeKey")
  16. }
  17. }
  18. var showDisplayView: Bool = false //显示左侧View界面
  19. var showRightSide: Bool = false //显示右侧界面
  20. var isPageEditMode: Bool = false //页面编辑模式
  21. var isPDFReadMode: Bool = false //阅读模式
  22. var editType: KMPDFEditModeType = .none
  23. //分屏PDF
  24. var splitPDFFileURL: URL?
  25. var splitPDFFilePassword: String?
  26. var splitSyncScroll: Bool = true
  27. var splitShowBottomBar: Bool = true
  28. override init() {
  29. super.init()
  30. self.initData()
  31. }
  32. func initData() {
  33. }
  34. }
  35. //MARK: - Annotation注释
  36. extension KMPDFViewManager {
  37. class func getValidPDFAnnotationType(_ subToolMode: KMPDFSubToolMode?) -> CAnnotationType {
  38. if subToolMode == .Highlight {
  39. return .highlight
  40. } else if subToolMode == .Underline {
  41. return .underline
  42. } else if subToolMode == .Waveline {
  43. return .squiggly
  44. } else if subToolMode == .Strikethrough {
  45. return .strikeOut
  46. } else if subToolMode == .Text {
  47. return .freeText
  48. } else if subToolMode == .Note {
  49. return .anchored
  50. } else if subToolMode == .Pen {
  51. return .ink
  52. } else if subToolMode == .Eraser {
  53. return .eraser
  54. } else if subToolMode == .Rectangle {
  55. return .square
  56. } else if subToolMode == .Circle {
  57. return .circle
  58. } else if subToolMode == .Arrow {
  59. return .arrow
  60. } else if subToolMode == .Line {
  61. return .line
  62. } else if subToolMode == .Measure {
  63. } else if subToolMode == .Stamp {
  64. } else if subToolMode == .Sign {
  65. }
  66. return .unkown
  67. }
  68. }