123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- import Cocoa
- struct KMPrintPageRange {
- var type: PageRangeType = .allPage
- var pageString = ""
- var selectPages: [Int] = []
- var reversePrintOrder: Bool = false
-
- enum PageRangeType: String, CaseIterable {
- case allPage = "All Pages"
- case currentPage = "Current Page"
- case oddPage = "Odd Pages Only"
- case evenPage = "Even Pages Only"
- case custom = "e.g. 1,3-5,10"
-
- static func allValues() -> [String] {
- var array: [String] = []
- for key in PageRangeType.allCases {
- array.append(NSLocalizedString(key.rawValue, comment: ""))
- }
- 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 = "Document and Markups"
- case documentAndForm = "Comments & Forms:"
- case documentAndStamp = "Document and Stamps"
-
- static func allValues() -> [String] {
- var array: [String] = []
- for key in KMPrintContentType.allCases {
- array.append(NSLocalizedString(key.rawValue, comment: ""))
- }
- 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
- }
- }
- enum KMPrintModelType {
- case size
- case poster
- case multipage
- case pamphlet
- }
- struct KMPrintPageOperation {
- var type: KMPrintModelType = .size
- var size: Size = Size()
- var isAutoRotate: Bool = false
-
- var poster: Poster = Poster()
- var multipage: Multipage = Multipage()
- var pamphlet: Pamphlet = Pamphlet()
-
- var pageOfPaper: PageOfPaper = PageOfPaper()
-
- struct PageOfPaper {
- var type: PageType = .page {
- didSet {
- if type != .custom {
- self.point = PageType.pointWithType(type)
- }
- }
- }
- 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)
- }
- 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 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 lineSpacing: CGFloat = 30
- var columnsSpacing: CGFloat = 30
- var isBorder: Bool = false
-
-
- enum Order: String, CaseIterable {
- case horizontal = "Horizontal"
- case horizontalReverseSequence = "Horizontal Reversed"
- case vertical = "Vertical"
- case verticalReverseSequence = "Vertical Reversed"
-
- static func allValues() -> [String] {
- var array: [String] = []
- for key in Order.allCases {
- array.append(NSLocalizedString(key.rawValue, comment: ""))
- }
- return array
- }
- }
- }
-
- struct Pamphlet {
- var type: PamphletType = .doubleSided
- var pageIndex: Int = 1
- var toPageIndex: Int = 1
- var bookbindingType: BookbindingType = .leftHigh
- var margin: CGFloat = 0.0
-
- enum PamphletType: String, CaseIterable {
- case doubleSided = "Both sides"
- case onlyPositive = "Front side only"
- case onlyBack = "Back side only"
-
- static func allValues() -> [String] {
- var array: [String] = []
- for key in PamphletType.allCases {
- array.append(NSLocalizedString(key.rawValue, comment: ""))
- }
- return array
- }
- }
-
- enum BookbindingType: String, CaseIterable {
- case left = "Left"
- case right = "Right"
- case leftHigh = "Left (Tall)"
- case rightHigh = "Right (Tall)"
-
- static func allValues() -> [String] {
- var array: [String] = []
- for key in BookbindingType.allCases {
- array.append(NSLocalizedString(key.rawValue, comment: ""))
- }
- return array
- }
- }
-
- }
- }
- class KMPrintPageModel: NSObject {
- var range: KMPrintPageRange = KMPrintPageRange()
- var contentType: KMPrintContentType = .document
- var operation: KMPrintPageOperation = KMPrintPageOperation()
- }
|