Browse Source

【编辑工具】水印、背景、页眉页脚 加密文件兼容

lizhe 1 year ago
parent
commit
011f508183

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/New/View/KMHeaderFooterView.swift

@@ -179,7 +179,7 @@ class KMHeaderFooterView: KMBaseXibView, NSTextViewDelegate, NSComboBoxDelegate
         didSet {
             self.pdfView.document = self.pdfDocument
             self.pdfView.headerFooter = self.headerFooterObj
-            
+            self.password = self.pdfDocument?.password ?? ""
             self._fileAttri = KMFileAttribute()
             self._fileAttri?.filePath = self.pdfDocument?.documentURL.path ?? ""
             

+ 1 - 0
PDF Office/PDF Master/Class/PDFTools/Background/New/View/KMAddBackgroundView.swift

@@ -87,6 +87,7 @@ class KMAddBackgroundView: KMBaseXibView, NSComboBoxDelegate {
     var type: KMBackgroundManagerType = .use
     var pdfDocument: CPDFDocument? {
         didSet {
+            self.password = pdfDocument?.password ?? ""
             self.pdfView.document = pdfDocument
             self.reloadData()
         }

+ 3 - 2
PDF Office/PDF Master/Class/PDFTools/Watermark/New/View/KMWatermarkView.swift

@@ -99,10 +99,10 @@ class KMWatermarkView: KMBaseXibView, NSTextFieldDelegate, NSComboBoxDelegate, N
         didSet {
             self._fileAttri = KMFileAttribute()
             self._fileAttri?.filePath = self.pdfDocument?.documentURL?.path ?? ""
-            
+            self.password = pdfDocument?.password ?? ""
             DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.3) {
                 self.pdfView.watermark = self.watermark
-                self.pdfView.document = CPDFDocument(url: self.pdfDocument?.documentURL)
+                self.pdfView.document = self.pdfDocument
             }
 //            self.reloadData()
         }
@@ -1030,6 +1030,7 @@ extension KMWatermarkView {
         DispatchQueue.global().async {
             let waterDocument = CPDFDocument(url: self.pdfView.document.documentURL)
             guard let waterDocument = waterDocument else { return }
+            waterDocument.unlock(withPassword: self.password)
             var property: CPDFWatermark!
             var scale: CGFloat = model.scale
             if (!model.text.isEmpty) {