|
@@ -384,6 +384,11 @@ class KMPDFConvertImage: KMPDFConvert {
|
|
|
}
|
|
|
|
|
|
class KMPDFConvertPPT: KMPDFConvert {
|
|
|
+ override init() {
|
|
|
+ super.init()
|
|
|
+
|
|
|
+ self.convertType = .ppt
|
|
|
+ }
|
|
|
|
|
|
override func startConvert() {
|
|
|
if self.pathExtension.isEmpty {
|
|
@@ -391,32 +396,38 @@ class KMPDFConvertPPT: KMPDFConvert {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if (self.convertType == .ppt) {
|
|
|
- self.converter = CPDFConverterPPT(url: URL(fileURLWithPath: self.filePath), password: self.password)
|
|
|
- self.converter.delegate = self
|
|
|
- self.converter.convert(toFilePath: self.outputFilePath, pageIndexs: self.pages, options: nil)
|
|
|
- return
|
|
|
- }
|
|
|
+ self.converter = CPDFConverterPPT(url: URL(fileURLWithPath: self.filePath), password: self.password)
|
|
|
+ self.converter.delegate = self
|
|
|
+ self.converter.convert(toFilePath: self.outputFilePath, pageIndexs: self.pages, options: nil)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
class KMPDFConvertText: KMPDFConvert {
|
|
|
+ override init() {
|
|
|
+ super.init()
|
|
|
+
|
|
|
+ self.convertType = .text
|
|
|
+ }
|
|
|
+
|
|
|
override func startConvert() {
|
|
|
if self.pathExtension.isEmpty {
|
|
|
self.convertSuccessful(isSuccessful: false, errorInfo: nil)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if (self.convertType == .text) {
|
|
|
- self.converter = CPDFConverterTxt(url: URL(fileURLWithPath: self.filePath), password: self.password)
|
|
|
- self.converter.delegate = self
|
|
|
- self.converter.convert(toFilePath: self.outputFilePath, pageIndexs: self.pages, options: nil)
|
|
|
- return
|
|
|
- }
|
|
|
+ self.converter = CPDFConverterTxt(url: URL(fileURLWithPath: self.filePath), password: self.password)
|
|
|
+ self.converter.delegate = self
|
|
|
+ self.converter.convert(toFilePath: self.outputFilePath, pageIndexs: self.pages, options: nil)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
class KMPDFConvertCSV: KMPDFConvert {
|
|
|
+ override init() {
|
|
|
+ super.init()
|
|
|
+
|
|
|
+ self.convertType = .csv
|
|
|
+ }
|
|
|
+
|
|
|
override func startConvert() {
|
|
|
if self.pathExtension.isEmpty {
|
|
|
self.convertSuccessful(isSuccessful: false, errorInfo: nil)
|
|
@@ -439,46 +450,43 @@ class KMPDFConvertCSV: KMPDFConvert {
|
|
|
}
|
|
|
|
|
|
class KMPDFConvertExcel: KMPDFConvert {
|
|
|
+ override init() {
|
|
|
+ super.init()
|
|
|
+
|
|
|
+ self.convertType = .excel
|
|
|
+ }
|
|
|
+
|
|
|
override func startConvert() {
|
|
|
- if self.pathExtension.isEmpty {
|
|
|
+ if (self.pathExtension.isEmpty) {
|
|
|
self.convertSuccessful(isSuccessful: false, errorInfo: nil)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if (self.convertType == .excel) {
|
|
|
- self.converter = CPDFConverterExcel(url: URL(fileURLWithPath: self.filePath), password: self.password)
|
|
|
- self.converter.delegate = self
|
|
|
-
|
|
|
- let options = CPDFConvertExcelOptions()
|
|
|
- if (self.isExtractText) {
|
|
|
- options.contentOptions = .onlyText
|
|
|
- } else if (self.isExtractTable) {
|
|
|
- options.contentOptions = .onlyTable
|
|
|
- if (self.extractTableIndex == 0) {
|
|
|
- options.worksheetOptions = .forEachTable
|
|
|
- } else if (self.extractTableIndex == 1) {
|
|
|
- options.worksheetOptions = .forEachPage
|
|
|
- } else if (self.extractTableIndex == 2) {
|
|
|
- options.worksheetOptions = .forTheDocument
|
|
|
- }
|
|
|
+ self.converter = CPDFConverterExcel(url: URL(fileURLWithPath: self.filePath), password: self.password)
|
|
|
+ self.converter.delegate = self
|
|
|
+
|
|
|
+ let options = CPDFConvertExcelOptions()
|
|
|
+ if (self.isExtractText) {
|
|
|
+ options.contentOptions = .onlyText
|
|
|
+ } else if (self.isExtractTable) {
|
|
|
+ options.contentOptions = .onlyTable
|
|
|
+ if (self.extractTableIndex == 0) {
|
|
|
+ options.worksheetOptions = .forEachTable
|
|
|
+ } else if (self.extractTableIndex == 1) {
|
|
|
+ options.worksheetOptions = .forEachPage
|
|
|
+ } else if (self.extractTableIndex == 2) {
|
|
|
+ options.worksheetOptions = .forTheDocument
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ options.contentOptions = .allContent
|
|
|
+ if (self.isAllInOneSheet) {
|
|
|
+ options.worksheetOptions = .forTheDocument
|
|
|
} else {
|
|
|
- options.contentOptions = .allContent
|
|
|
- if (self.isAllInOneSheet) {
|
|
|
- options.worksheetOptions = .forTheDocument
|
|
|
- } else {
|
|
|
- options.worksheetOptions = .forEachPage
|
|
|
- }
|
|
|
+ options.worksheetOptions = .forEachPage
|
|
|
}
|
|
|
-
|
|
|
- self.converter.convert(toFilePath: self.outputFilePath, pageIndexs: self.pages, options: options)
|
|
|
- return
|
|
|
}
|
|
|
|
|
|
- self.fpPDFConverter = CPDFConverterFP()
|
|
|
- self.fpPDFConverter.setDelegate(self)
|
|
|
-
|
|
|
- let options: [String : Any] = [CPDFConvertOptionsKey.allInOneSheet.rawValue : self.isAllInOneSheet]
|
|
|
- self.fpPDFConverter.convertPDF(atPath: self.filePath, pdfPassword: self.password, pdfPageIndexs: self.pages, destDocType: self.pathExtension, destDocPath: self.outputFilePath, moreOptions: options)
|
|
|
+ self.converter.convert(toFilePath: self.outputFilePath, pageIndexs: self.pages, options: options)
|
|
|
}
|
|
|
}
|
|
|
|