Просмотр исходного кода

【2025】 【Convert】图片转PDF, 选择合并到现有文档,选择损坏文档, 会提示这个文档是加密的- 修复

lizhe 1 месяц назад
Родитель
Сommit
b804b761b3

+ 9 - 0
PDF Office/PDF Master/KMClass/NewBatch/View/Setting/ImageToPDF/KMBatchImageToPDFView.swift

@@ -308,6 +308,15 @@ extension KMBatchImageToPDFView {
         openPanel.beginSheetModal(for: self.window!) { (result) in
             if result == .OK {
                 guard let url = openPanel.url else { return }
+                
+                if !url.path.isPDFValid() {
+                    let alert = NSAlert()
+                    alert.alertStyle = .critical
+                    alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
+                    alert.runModal()
+                    return
+                }
+                
                 guard let document = CPDFDocument(url: url) else {
                     let alert = NSAlert()
                     alert.alertStyle = .critical