|
@@ -217,6 +217,129 @@ class KMPDFConvert: Operation {
|
|
|
dpi = self.options[KMPDFConvertOptionsKeyImageDPI] as! Int
|
|
|
}
|
|
|
let options: [String:Any] = [CPDFConvertOptionsKey.imageDPI.rawValue:dpi,CPDFConvertOptionsKey.allInOneSheet.rawValue:isAllInOneSheet]
|
|
|
+
|
|
|
+ if self.convertType == .word {
|
|
|
+ self.converter = CPDFConverterWord.init(url: URL(fileURLWithPath: filePath), password: self.password)
|
|
|
+ self.converter.delegate = self
|
|
|
+ let options = CPDFConvertWordOptions()
|
|
|
+ options.layoutOptions = self.isAllInOneSheet ? .retainPageLayout : .retainFlowingText
|
|
|
+ options.isContainAnnotations = true
|
|
|
+// options.isAllowOCR = self.isAllowOCR
|
|
|
+// if (self.isAllowOCR) {
|
|
|
+// options.isContainOCRBgImage = self.isContainOCRBgImage
|
|
|
+// if let language = self.ocrLanguage {
|
|
|
+// options.language = language
|
|
|
+// } else {
|
|
|
+// options.language = .english
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+ options.isContainImages = true
|
|
|
+// options.isContainOCRBgImage = false
|
|
|
+// }
|
|
|
+ self.converter.convert(toFilePath: self.outputFilePath, pageIndexs: self.pages, options: options)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if self.convertType == .excel {
|
|
|
+ self.converter = CPDFConverterExcel.init(url: URL(fileURLWithPath: filePath), password: self.password)
|
|
|
+ self.converter.delegate = self
|
|
|
+ let options = CPDFConvertExcelOptions()
|
|
|
+ options.isContainAnnotations = true
|
|
|
+// options.isAllowOCR = self.isAllowOCR
|
|
|
+// if (self.isAllowOCR) {
|
|
|
+// options.isContainOCRBgImage = self.isContainOCRBgImage
|
|
|
+// if let language = self.ocrLanguage {
|
|
|
+// options.language = language
|
|
|
+// } else {
|
|
|
+// options.language = .english
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+ options.isContainImages = true
|
|
|
+ options.isContainOCRBgImage = false
|
|
|
+// }
|
|
|
+
|
|
|
+ options.contentOptions = self.excelContentOption ?? .allContent
|
|
|
+ options.worksheetOptions = self.excelWorksheetOption ?? .forEachPage
|
|
|
+
|
|
|
+ self.converter.convert(toFilePath: self.outputFilePath, pageIndexs: self.pages, options: options)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if self.convertType == .ppt {
|
|
|
+ self.converter = CPDFConverterPPT.init(url: URL(fileURLWithPath: filePath), password: self.password)
|
|
|
+ self.converter.delegate = self
|
|
|
+ let options = CPDFConvertPPTOptions()
|
|
|
+ options.isContainAnnotations = true
|
|
|
+// options.isAllowOCR = self.isAllowOCR
|
|
|
+ options.isContainImages = true
|
|
|
+ self.converter.convert(toFilePath: self.outputFilePath, pageIndexs: self.pages, options: options)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if self.convertType == .csv{
|
|
|
+ self.converter = CPDFConverterCsv.init(url: URL(fileURLWithPath: filePath), password: self.password)
|
|
|
+ self.converter.delegate = self
|
|
|
+ let options = CPDFConvertCsvOptions()
|
|
|
+
|
|
|
+ self.converter.convert(toFilePath: self.outputFilePath, pageIndexs: self.pages, options: options)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if self.convertType == .rtf{
|
|
|
+ self.converter = CPDFConverterRtf.init(url: URL(fileURLWithPath: filePath), password: self.password)
|
|
|
+ self.converter.delegate = self
|
|
|
+ let options = CPDFConvertRtfOptions()
|
|
|
+ options.isContainAnnotations = true
|
|
|
+ options.isAllowOCR = true
|
|
|
+// if (self.isAllowOCR) {
|
|
|
+// options.isContainOCRBgImage = self.isContainOCRBgImage
|
|
|
+// if let language = self.ocrLanguage {
|
|
|
+// options.language = language
|
|
|
+// } else {
|
|
|
+// options.language = .english
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+ options.isContainImages = true
|
|
|
+// options.isContainOCRBgImage = false
|
|
|
+// }
|
|
|
+ self.converter.convert(toFilePath: self.outputFilePath, pageIndexs: self.pages, options: options)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if self.convertType == .html{
|
|
|
+ self.converter = CPDFConverterHtml.init(url: URL(fileURLWithPath: filePath), password: self.password)
|
|
|
+ self.converter.delegate = self
|
|
|
+ let options = CPDFConvertHtmlOptions()
|
|
|
+ options.isContainAnnotations = true
|
|
|
+ options.isAllowOCR = true
|
|
|
+// if (self.isAllowOCR) {
|
|
|
+// options.isContainOCRBgImage = self.isContainOCRBgImage
|
|
|
+// if let language = self.ocrLanguage {
|
|
|
+// options.language = language
|
|
|
+// } else {
|
|
|
+// options.language = .english
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+ options.isContainImages = true
|
|
|
+// options.isContainOCRBgImage = false
|
|
|
+// }
|
|
|
+ self.converter.convert(toFilePath: self.outputFilePath, pageIndexs: self.pages, options: options)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if self.convertType == .text{
|
|
|
+ self.converter = CPDFConverterTxt.init(url: URL(fileURLWithPath: filePath), password: self.password)
|
|
|
+ self.converter.delegate = self
|
|
|
+ let options = CPDFConvertTxtOptions()
|
|
|
+ options.isAllowOCR = self.isAllowOCR
|
|
|
+ if (self.isAllowOCR) {
|
|
|
+ if let language = self.ocrLanguage {
|
|
|
+ options.language = language
|
|
|
+ } else {
|
|
|
+ options.language = .english
|
|
|
+ }
|
|
|
+ }
|
|
|
+ self.converter.convert(toFilePath: self.outputFilePath, pageIndexs: self.pages, options: options)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
fpPDFConverter.convertPDF(atPath: filePath, pdfPassword: self.password, pdfPageIndexs: pages, destDocType: pathExtension, destDocPath: outputFilePath, moreOptions: options)
|
|
|
}
|
|
|
|