     
     class open func isValidPDF(fileURL: URL) -> Bool {
         do {
-            let data = try Data(contentsOf: fileURL)
-            return isValidPDF(data: data)
+            return isValidPDF(data: try Data(contentsOf: fileURL))
         } catch {
             return false
         }

        guard scaleFactor > 0.0 else {
            return nil
        }
        
        return autoreleasepool { () -> Data in
            let data = NSMutableData()
            let pageCount = images.count - 1
            
            autoreleasepool {
                let options = (password != nil) ? self.toDocumentInfo(password: password!) : nil
                UIGraphicsBeginPDFContextToData(data, .zero, options)
                
                for index in 0...pageCount {
                    let bounds = CGRect(
                        origin: .zero,
                        size: CGSize(
                            width: images[index].size.width * scaleFactor,
                            height: images[index].size.height * scaleFactor
                        )
                    )
                    UIGraphicsBeginPDFPageWithInfo(bounds, nil)
                    images[index].draw(in: bounds)
                }
                UIGraphicsEndPDFContext()
            }
            
            return data as Data
        }
    }
    
}

        return data as Data
    }
    
    class open func addPassword(fileURL: URL, password: String) -> Data? {
        do {
            return addPassword(data: try Data(contentsOf: fileURL), password: password)
        } catch {
            return nil
        }
    }
    
    class open func addPassword(data: Data, password: String) -> Data? {
        if let provider = CGDataProvider(data: data as CFData) {
            if let pdf = CGPDFDocument(provider) {
                return convertPdfToData(pdf: pdf, password: password)
            }
        }
        return nil
    }
    
    class open func removePassword(fileURL: URL, password: String) throws -> Data? {
        return try removePassword(data: try Data(contentsOf: fileURL), password: password)
    }
    
    class open func removePassword(data: Data, password: String) throws -> Data? {
        if let pdf = unlock(data: data, password: password) {
            return convertPdfToData(pdf: pdf)
        }
        return nil
    }
    
    class open func convertPDFToImages(fileURL: URL, password: String? = nil) throws -> [UIImage]? {
        return try convertPDFToImages(data: try Data(contentsOf: fileURL), password: password)
    }
    
    class open func convertPDFToImages(data: Data, password: String? = nil) throws -> [UIImage]? {
        if let provider = CGDataProvider(data: data as CFData) {
            if let pdf = CGPDFDocument(provider) {
                return convertPDFToImages(pdf: pdf, password: password)
            }
        }
        return nil
    }
    
    class open func convertPDFToImages(pdf: CGPDFDocument, password: String? = nil) -> [UIImage]? {
