title: share PDF file with UIActivityViewController
body: <p>I am trying to share a PDF file using <code>UIActivityViewController</code> but when I press the button I do not have options to share the file
  How can I show these options ?</p>
  
  <p>![](<a href="https://i.stack.imgur.com/ywDQw.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/ywDQw.jpg</a></p>
  
  <pre><code>import UIKit
  import PDFKit
  import MessageUI
  import UIKit.UIGestureRecognizerSubclass
  
  class BookViewController: UIViewController, UIPopoverPresentationControllerDelegate, PDFViewDelegate, ActionMenuViewControllerDelegate, OutlineViewControllerDelegate, MFMailComposeViewControllerDelegate {
  
      @IBOutlet weak var btn: UIButton!
  
      var pdfDocument: PDFDocument?
  
      @IBOutlet weak var pdfView: PDFView!
      @IBOutlet weak var webview: UIWebView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          pdfView.autoScales = true
          pdfView.displayMode = .singlePage
          pdfView.displayDirection = .horizontal
          pdfView.usePageViewController(true, withViewOptions: [UIPageViewControllerOptionInterPageSpacingKey: 20])
  
          pdfView.document = pdfDocument
          resume()
  
  
          // ActivityViewController
      }
  
  
      override func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) {
          coordinator.animate(alongsideTransition: { (context) in
          }, completion: nil)
      }
  
      func adaptivePresentationStyle(for controller: UIPresentationController) -&gt; UIModalPresentationStyle {
          return .none
      }
  
      func actionMenuViewControllergmailDocument(_ actionMenuViewController: ActionMenuViewController) {
  
      }
  
      func actionMenuViewControllerShareDocument(_ actionMenuViewController: ActionMenuViewController) {
  
  
      }
  
      func actionMenuViewControllerPrintDocument(_ actionMenuViewController: ActionMenuViewController) {
  
      }
  
      func outlineViewController(_ outlineViewController: OutlineViewController, didSelectOutlineAt destination: PDFDestination) {
          resume()
          pdfView.go(to: destination)
      }
  
      private func resume() {
          let backButton = UIBarButtonItem(image: #imageLiteral(resourceName: "Chevron"), style: .plain, target: self, action: #selector(back(_:)))
          let actionButton = UIBarButtonItem(barButtonSystemItem: .action, target: self, action: #selector(showActionMenu(_:)))
          navigationItem.leftBarButtonItems = [backButton, actionButton]
          pdfView.isHidden = false
      }
  
      @objc func resume(_ sender: UIBarButtonItem) {
          resume()
      }
  
      @objc func back(_ sender: UIBarButtonItem) {
          navigationController?.popViewController(animated: true)
      }
  
      @objc func showActionMenu(_ sender: UIBarButtonItem) {
          if let viewController = storyboard?.instantiateViewController(withIdentifier: String(describing: ActionMenuViewController.self)) as? ActionMenuViewController {
              let activityVC = UIActivityViewController(activityItems: [self.pdfDocument!], applicationActivities: nil)
              activityVC.popoverPresentationController?.sourceView = self.view
  
              self.present(activityVC, animated: true, completion: nil)
          }
      }
  }
  </code></pre>