|
@@ -17,7 +17,7 @@ import ComPDFKit_Tools
|
|
|
*/
|
|
|
@objc(ComPDFKit)
|
|
|
class ComPDFKit: NSObject, CPDFViewBaseControllerDelete{
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Get the version number of the ComPDFKit SDK.<br/>
|
|
|
* For example: "2.0.0".<br/>
|
|
@@ -54,8 +54,8 @@ class ComPDFKit: NSObject, CPDFViewBaseControllerDelete{
|
|
|
let sdkBuildTag = CPDFKit.sharedInstance().versionString
|
|
|
resolve(sdkBuildTag)
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* Initialize the ComPDFKit PDF SDK using offline authentication.<br/>
|
|
|
* <p></p>
|
|
@@ -74,8 +74,8 @@ class ComPDFKit: NSObject, CPDFViewBaseControllerDelete{
|
|
|
resolve(code == CPDFKitLicenseCode.success)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* Initialize the ComPDFKit PDF SDK using online authentication. <br/>
|
|
|
* Requires internet connection. Please ensure that the network permission has been added in [AndroidManifest.xml] file. <br/>
|
|
@@ -98,8 +98,8 @@ class ComPDFKit: NSObject, CPDFViewBaseControllerDelete{
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* Display a PDF.<br/>
|
|
|
*
|
|
@@ -134,18 +134,18 @@ class ComPDFKit: NSObject, CPDFViewBaseControllerDelete{
|
|
|
let samplesFilePath = NSHomeDirectory().appending("/Documents/Files")
|
|
|
let fileName = document.lastPathComponent
|
|
|
let docsFilePath = samplesFilePath + "/" + fileName
|
|
|
-
|
|
|
+
|
|
|
if !fileManager.fileExists(atPath: samplesFilePath) {
|
|
|
try? FileManager.default.createDirectory(atPath: samplesFilePath, withIntermediateDirectories: true, attributes: nil)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
try? FileManager.default.copyItem(atPath: document.path, toPath: docsFilePath)
|
|
|
-
|
|
|
+
|
|
|
let rootNav = ComPDFKit.presentedViewController()
|
|
|
-
|
|
|
+
|
|
|
let jsonDataParse = CPDFJSONDataParse(String: configurationJson)
|
|
|
guard let configuration = jsonDataParse.configuration else { return }
|
|
|
-
|
|
|
+
|
|
|
let pdfViewController = CPDFViewController(filePath: docsFilePath, password: password, configuration: configuration)
|
|
|
pdfViewController.delegate = self
|
|
|
let nav = CNavigationController(rootViewController: pdfViewController)
|
|
@@ -153,46 +153,46 @@ class ComPDFKit: NSObject, CPDFViewBaseControllerDelete{
|
|
|
rootNav?.present(nav, animated: true)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* CPDFViewBaseControllerDelete delegate to dismiss ViewController.<br/>
|
|
|
*/
|
|
|
func PDFViewBaseControllerDissmiss(_ baseControllerDelete: CPDFViewBaseController) {
|
|
|
baseControllerDelete.dismiss(animated: true)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Cet a root ViewController.<br/>
|
|
|
*/
|
|
|
class func presentedViewController() -> UIViewController? {
|
|
|
-
|
|
|
+
|
|
|
var rootViewController: UIViewController? = nil
|
|
|
-
|
|
|
+
|
|
|
if let appDelegate = UIApplication.shared.delegate as? NSObject {
|
|
|
if appDelegate.responds(to: Selector(("viewController"))) {
|
|
|
rootViewController = appDelegate.value(forKey: "viewController") as? UIViewController
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if rootViewController == nil, let appDelegate = UIApplication.shared.delegate as? NSObject, appDelegate.responds(to: #selector(getter: UIApplicationDelegate.window)) {
|
|
|
if let window = appDelegate.value(forKey: "window") as? UIWindow {
|
|
|
rootViewController = window.rootViewController
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if rootViewController == nil {
|
|
|
if let window = UIApplication.shared.keyWindow {
|
|
|
rootViewController = window.rootViewController
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
guard let finalRootViewController = rootViewController else {
|
|
|
return nil
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var currentViewController = finalRootViewController
|
|
|
-
|
|
|
+
|
|
|
while let presentedViewController = currentViewController.presentedViewController {
|
|
|
if !(presentedViewController is UIAlertController) && currentViewController.modalPresentationStyle != .popover {
|
|
|
currentViewController = presentedViewController
|
|
@@ -200,8 +200,14 @@ class ComPDFKit: NSObject, CPDFViewBaseControllerDelete{
|
|
|
return currentViewController
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return currentViewController
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @objc(removeSignFileList:withRejecter:)
|
|
|
+ func removeSignFileList(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
|
|
|
+ // TODO: 清空注释电子签名文件列表,返回true、false
|
|
|
+ resolve(true)
|
|
|
+ }
|
|
|
+
|
|
|
}
|