         
         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)
                 
-                let bounds = CGRect(
-                    origin: .zero,
-                    size: CGSize(
-                        width: image.size.width * scaleFactor,
-                        height: image.size.height * scaleFactor
+                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)
-                image.draw(in: bounds)
-                
+                    UIGraphicsBeginPDFPageWithInfo(bounds, nil)
+                    images[index].draw(in: bounds)
+                }
                 UIGraphicsEndPDFContext()
             }
             

        return autoreleasepool { () -> Bool in
            do {
                let data = try Data(contentsOf: fileURL)
                return canUnlock(input: data, password: password)
            } catch {
                return false
            }
        }
    }
    
    class open func canUnlock(input: Data, password: String) -> Bool {
        return autoreleasepool { () -> Bool in
            let dataProvider = CGDataProvider(data: input as CFData)
            let pdf = CGPDFDocument(dataProvider!)
            
            // Try a blank password first, per Apple's Quartz PDF example

        return try autoreleasepool { () -> Data? in
            do {
                let data = try Data(contentsOf: fileURL)
                return try addPassword(data: data, password: password)
            } catch {
                return nil
            }
        }
    }
    
    class open func addPassword(data: Data, password: String) throws -> Data? {
        return try autoreleasepool { () -> Data? in
            let dataProvider = CGDataProvider(data: data as CFData)
            if let provider = dataProvider {
                if let pdf = CGPDFDocument(provider) {
                    return try convertPdfToData(pdf: pdf, password: password)
