// // KMPrintPageModel.swift // PDF Master // // Created by lizhe on 2022/12/21. // import Cocoa struct KMPrintPageRange { var type: PageRangeType = .allPage var selectPages: [Int] = [] //选中页面 var reversePrintOrder: Bool = false //逆页面打印 enum PageRangeType: String, CaseIterable { case allPage = "All Pages" //全部页面 case currentPage = "Current Page" //当前页面 case oddPage = "Odd Page" //奇数页 case evenPage = "Even Page" //偶数页 case custom = "Custom" //自定义页面 static func allValues() -> [String] { var array: [String] = [] for key in PageRangeType.allCases { array.append(key.rawValue) } return array } static func typeOfRawValue(_ rawValue: String) -> PageRangeType { var type: PageRangeType = .allPage switch rawValue { case PageRangeType.allPage.rawValue, NSLocalizedString(PageRangeType.allPage.rawValue, comment: ""): type = .allPage case PageRangeType.currentPage.rawValue, NSLocalizedString(PageRangeType.currentPage.rawValue, comment: ""): type = .currentPage case PageRangeType.oddPage.rawValue, NSLocalizedString(PageRangeType.oddPage.rawValue, comment: ""): type = .oddPage case PageRangeType.custom.rawValue, NSLocalizedString(PageRangeType.custom.rawValue, comment: ""): type = .custom default: type = .allPage } return type } } } enum KMPrintContentType: String, CaseIterable { case document = "document" //文档 case documentAndMarkup = "documentAndMarkup" //文档和标签 case documentAndForm = "documentAndForm" //文档和表单 case documentAndStamp = "documentAndStamp" //文档和贴图 static func allValues() -> [String] { var array: [String] = [] for key in KMPrintContentType.allCases { array.append(key.rawValue) } return array } static func typeOfRawValue(_ rawValue: String) -> KMPrintContentType { var type: KMPrintContentType = .document switch rawValue { case KMPrintContentType.document.rawValue, NSLocalizedString(KMPrintContentType.document.rawValue, comment: ""): type = .document case KMPrintContentType.documentAndMarkup.rawValue, NSLocalizedString(KMPrintContentType.documentAndMarkup.rawValue, comment: ""): type = .documentAndMarkup case KMPrintContentType.documentAndForm.rawValue, NSLocalizedString(KMPrintContentType.documentAndForm.rawValue, comment: ""): type = .documentAndForm case KMPrintContentType.documentAndStamp.rawValue, NSLocalizedString(KMPrintContentType.documentAndStamp.rawValue, comment: ""): type = .documentAndStamp default: type = .document } return type } } struct KMPrintPageOperation { var type: ModelType = .size var size: Size = Size() var poster: Poster = Poster() var multipage: Multipage = Multipage() var pamphlet: Pamphlet = Pamphlet() //类型 enum ModelType { case size //大小 case poster //海报 case multipage //多页 case pamphlet //小册子 } struct PageOfPaper { var type: PageType = .page var point: CGPoint = CGPoint(x: 1, y: 1) enum PageType: String, CaseIterable { case page = "1" case page2 = "2" case page4 = "4" case page6 = "6" case page9 = "9" case page16 = "16" case custom = "custom" static func allValues() -> [String] { var array: [String] = [] for key in PageType.allCases { array.append(key.rawValue) } array.removeObject("1") return array } static func pointWithType(_ type: PageType) -> CGPoint { var point: CGPoint = CGPoint(x: 1, y: 1) switch type { case .page: point = CGPoint(x: 1, y: 1) case .page2: point = CGPoint(x: 1, y: 2) case .page4: point = CGPoint(x: 2, y: 2) case .page6: point = CGPoint(x: 2, y: 3) case .page9: point = CGPoint(x: 3, y: 3) case .page16: point = CGPoint(x: 4, y: 4) default: point = CGPoint(x: 1, y: 1) } return point } } } //大小模式参数内容 struct Size { var model: Model = .auto var scale: CGFloat = 1.0 var duplexPrintModel: KMPrintPrinterModel? //双面打印 enum Model: String { case auto = "auto" case full = "full" case custom = "custom" } } //海报模式参数内容 struct Poster { var type: PosterType = .tile var scale: CGFloat = 1.0 var tilePoint: CGPoint = CGPoint(x: 1, y: 1) var pageOfPaper: PageOfPaper = PageOfPaper() var overlap: Float = 0.0 var isCutMark: Bool = false var isTags: Bool = false var tags: [String] = ["(column,row)1.pdf 2023-01-09 05:49:54"] enum PosterType { case tile //平铺 case breakUp //拆分 } } //多页模式参数内容 struct Multipage { var orderType: Order = .horizontal var pageOfPaper: PageOfPaper = PageOfPaper() var isAutoRotate: Bool = false //自动旋转 //排序类型 enum Order: String, CaseIterable { case horizontal = "Horizontal" //横向 case horizontalReverseSequence = "Horizontal Reverse Sequence" //横向倒序 case vertical = "Vertical" //纵向 case verticalReverseSequence = "Vertical Reverse Sequence" //纵向倒序 static func allValues() -> [String] { var array: [String] = [] for key in Order.allCases { array.append(key.rawValue) } return array } } } //小册子模式参数内容 struct Pamphlet { var type: PamphletType = .doubleSided var pageIndex: Int = 1 var toPageIndex: Int = 1 var bookbindingType: BookbindingType = .left var isAutoRotate: Bool = false //自动旋转 enum PamphletType: String, CaseIterable { case doubleSided = "Double Sided" //双面 case onlyPositive = "Only Positive" //正面 case onlyBack = "Only Back" //背面 case verticalReverseSequence = "Vertical Reverse Sequence" //纵向倒序 static func allValues() -> [String] { var array: [String] = [] for key in PamphletType.allCases { array.append(key.rawValue) } return array } } enum BookbindingType: String, CaseIterable { case left = "Left" //左 case right = "Right" //右 case leftHigh = "Left(High)" //左高 case rightHigh = "Right(High)" //右高 static func allValues() -> [String] { var array: [String] = [] for key in BookbindingType.allCases { array.append(key.rawValue) } return array } } } } class KMPrintPageModel: NSObject { var range: KMPrintPageRange = KMPrintPageRange() //页面范围 var contentType: KMPrintContentType = .document //页面内容 var operation: KMPrintPageOperation = KMPrintPageOperation() //页面操作类型 }