             self.saveAndClose()
         }
     }
+    
+    // MARK: UIDocumentBrowserViewControllerDelegate
+
+    func searchBarTextDidEndEditing(_ searchBar: UISearchBar) {
+        if (searchBar.text != nil) {
+            let selection = PDFSelection.init(document: self.pdfView.document!)
+            if let selection = pdfView.document?.findString(searchBar.text!, fromSelection: selection, withOptions: .regularExpression) {
+                pdfView.setCurrentSelection(selection, animate: true)
+            }
+        }
+    }
 }

            }
            view.backgroundColor = presentingViewController?.view.backgroundColor
            navigationController?.navigationBar.tintColor = presentingViewController?.view.tintColor
        }
    }
    
    override var prefersStatusBarHidden: Bool {
        return navigationController?.isNavigationBarHidden == true || super.prefersStatusBarHidden
    }
    
    override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {

    }
    
    override func viewDidLoad() {
        navigationController?.hidesBarsOnTap = true
        
        let searchController = UISearchController(searchResultsController: nil)
        searchController.searchBar.delegate = self
        navigationItem.searchController = searchController
        navigationItem.hidesSearchBarWhenScrolling = false
        
        pdfView.autoScales = true
        pdfView.displaysPageBreaks = false
