|
@@ -347,7 +347,7 @@ extension KMTools {
|
|
|
return NSLocalizedString("e.g. 1,3-5,10", comment: "")
|
|
|
}
|
|
|
|
|
|
- @objc class func saveDocumentForWatermark(document: CPDFDocument, to url: URL) -> URL? {
|
|
|
+ @objc class func saveDocumentForWatermark(document: CPDFDocument, to url: URL, secureOptions: [CPDFDocumentWriteOption : Any]? = nil, removePWD: Bool = false) -> URL? {
|
|
|
// 将文档存入临时目录
|
|
|
if let data = self.getTempFloderPath(), !FileManager.default.fileExists(atPath: data) {
|
|
|
try?FileManager.default.createDirectory(atPath: data, withIntermediateDirectories: false)
|
|
@@ -411,7 +411,13 @@ extension KMTools {
|
|
|
}
|
|
|
|
|
|
// 保存文档
|
|
|
- _document.write(to: url)
|
|
|
+ if let data = secureOptions, !data.isEmpty {
|
|
|
+ _document.write(to: url, withOptions: data)
|
|
|
+ } else if (removePWD) {
|
|
|
+ document.writeDecrypt(to: url)
|
|
|
+ } else {
|
|
|
+ _document.write(to: url)
|
|
|
+ }
|
|
|
// 清除临时数据
|
|
|
if (FileManager.default.fileExists(atPath: filePath)) {
|
|
|
try?FileManager.default.removeItem(atPath: filePath)
|