Browse Source

【转档工具】- 导出图片

liujiajie 1 year ago
parent
commit
1ff3cbf316

+ 3 - 3
PDF Office/PDF Master/Class/PDFTools/Convert/ExtractImage/Model/PDFConvertObject.swift

@@ -39,11 +39,11 @@ class PDFConvertObject: NSObject{
     }
     func extractResourcesFromPDF(at pdfPathA: String, pdfPassword pdfPasswordA: String?, selectIndexSet indexSet: IndexSet, destDocPath destDocPathA: String, moreOptions moreOptionsA: [AnyHashable: Any]?) {
         self.document = CPDFDocument(url: URL(fileURLWithPath: pdfPathA))
-        if let pdfPassword = pdfPasswordA {
-            self.document?.unlock(withPassword: pdfPassword)
+        if pdfPasswordA?.count ?? 0 > 0 {
+            self.document?.unlock(withPassword: pdfPasswordA)
         }
         self.document?.extractImage(fromPages: indexSet, toPath: destDocPathA) { (pageIndex, imageIndex, index) -> String? in
-            let fileName = self.document?.documentURL.lastPathComponent.deletingPathExtension
+            let fileName = self.document?.documentURL.deletingPathExtension().lastPathComponent
             let imageName = String(format: "%@_Page%ld_%@", fileName ?? "",pageIndex+1,self.imageNumberSuffix(imageIndex+1))
             return imageName
         }