         pages.append(page)
     }
     
-    open func generate() {
+    open func generate(inDirectory: String? = nil) {
         
         if let filename = filename {
             _filename = filename

        
        _filename = _filename.sanitizedPDFFilenameString
        
        let tmpPath = NSString(string: NSTemporaryDirectory()).appendingPathComponent(_filename)
        
        pdfPath = tmpPath
        
        // Define PDF context
        

                               size: defaultPageSize.size)
        }
        
        UIGraphicsBeginPDFContextToFile(storagePath, pagesSize, pdfMetadata)
        
        // Perform draw pages
        
