         var buttons: [UIBarButtonItem] = []
         
         if allowsSharing {
-            buttons.append(UIBarButtonItem(
+            let shareFormBarButtonItem = UIBarButtonItem(
                 barButtonSystemItem: .action,
                 target: self,
                 action: #selector(PDFViewController.shareForm)
-                )
             )
+            buttons.append(shareFormBarButtonItem)
+            self.shareFormBarButtonItem = shareFormBarButtonItem
         }
         
         if allowsFormFilling {

    var collectionView: PDFSinglePageViewer!
    
    var pageScrubber: PDFPageScrubber!
    
    public var scrollDirection: UICollectionViewScrollDirection = .horizontal
    

        if UIDevice.current.userInterfaceIdiom == .pad {
            activityVC.modalPresentationStyle = .popover
            let popController = activityVC.popoverPresentationController
            popController?.barButtonItem = shareFormBarButtonItem
            popController?.permittedArrowDirections = .up
        }
        present(activityVC, animated: true, completion: nil)
