// // KMConvertImageWindowController.swift // PDF Master // // Created by tangchao on 2022/12/6. // // 转档 转图片 窗口 class KMConvertImageWindowController: KMConvertBaseWindowController { override func initDefaultValue() { super.initDefaultValue() self.titleLabel.stringValue = NSLocalizedString("PDF to Image", comment: "") } override func initSettingView() -> KMConvertSettingView? { return KMConvertImageSettingView.createFromNib() } override func initConvert() -> KMPDFConvert { return KMPDFConvertImage() } override var fileExtension: String { let settingView: KMConvertImageSettingView = self.settingView as! KMConvertImageSettingView if (settingView.selectedFormatIndex == 0 || settingView.selectedFormatIndex == 2) { return "zip" } return super.fileExtension } override func convertModelAppendParams(convert: KMPDFConvert) { let settingView: KMConvertImageSettingView = self.settingView as! KMConvertImageSettingView if (settingView.selectedFormatIndex == 0) { convert.convertType = .jpeg } else if (settingView.selectedFormatIndex == 1) { convert.convertType = .jpg } else if (settingView.selectedFormatIndex == 2) { convert.convertType = .png } else if (settingView.selectedFormatIndex == 3) { convert.convertType = .gif } else if (settingView.selectedFormatIndex == 4) { convert.convertType = .tiff } else if (settingView.selectedFormatIndex == 5) { convert.convertType = .tga } else if (settingView.selectedFormatIndex == 6) { convert.convertType = .bmp } else if (settingView.selectedFormatIndex == 7) { convert.convertType = .jp2 } else { convert.convertType = .jpeg } var dpi: Int = 150 if settingView.selectedResolutionIndex == 0 { dpi = 50 } else if settingView.selectedResolutionIndex == 1 { dpi = 72 } else if settingView.selectedResolutionIndex == 2 { dpi = 96 } else if settingView.selectedResolutionIndex == 3 { dpi = 150 } else if settingView.selectedResolutionIndex == 4 { dpi = 300 } else if settingView.selectedResolutionIndex == 5 { dpi = 600 } else { dpi = 150 } if let _convert = convert as? KMPDFConvertImage { if (convert.convertType == .jpeg) { _convert.imageType = .JPEG _convert.imageDpi = dpi } else if (convert.convertType == .png) { _convert.imageType = .PNG _convert.imageDpi = dpi } else { _convert.imageDpi = 150 } } } }