首页 > 解决方案 > 从 WKWebView 中显示的 PDF 中获取页码以进行书签

问题描述

我已经实现了 WKWebView 并在其中显示了一个 PDF 文件,现在我想为页面添加书签。为此我需要知道

1) How to get current Page Number of PDF displayed
2) How to scroll WKWebView to that page number later on.

到目前为止,我已经这样做了:

          let pathOfPDF = URL(fileURLWithPath: Bundle.main.path(forResource: "pdfFile", ofType: "pdf")!)
      let request = URLRequest(url: pathOfPDF)

     pdfView.frame = CGRect(x: view.frame.width/26, y: view.frame.height/12.5, width: view.frame.width-view.frame.width/13, height: view.frame.height - view.frame.height/12.5)

    pdfView.uiDelegate = self
    activityIndicatorIcon.hidesWhenStopped = true
    pdfView.allowsBackForwardNavigationGestures = true
    pdfView.load(request)
    pdfView.navigationDelegate = self

标签: iosswiftxcodepdfwkwebview

解决方案


推荐阅读