iOS端 使用Mupdf实现pdf标注

2021-03-31  本文已影响0人  133sheiya

项目中如果需要实现在pdf做标注。大可使用mupdf(开源的)

最后再看下我项目中如何使用

  1. command + B 获取 真机下的framework 我这里没有做模拟器的framework 需要的自己去合并 .

    image.png
  2. mupdfdk.framework拖入到工程中

    image.png
  3. 配置mupdfdk.framework

    image.png
  4. 测试

 let fileManager = FileManager.default
        let docsDir = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
        let filePath1 = Bundle.main.path(forResource: "iOS_20200804172410", ofType: "pdf") ?? ""
        let filePath2 = Bundle.main.path(forResource: "rk", ofType: "pdf") ?? ""
        if !fileManager.fileExists(atPath: docsDir + "/rk.pdf") {
           try? fileManager.copyItem(atPath: filePath2, toPath: docsDir + "/rk.pdf")
        }
        if !fileManager.fileExists(atPath: docsDir + "/iOS_20200804172410.pdf") {
           try? fileManager.copyItem(atPath: filePath1, toPath: docsDir + "/iOS_20200804172410.pdf")
        }

 @objc func btnClickAction() {
       
        if  let vc = CustomUIDocumentViewController(forPath: "iOS_20200804172410.pdf") {
            self.navigationController?.pushViewController(vc, animated: true)
        }
        
    }
    
    @objc func btnClickAction1() {
       
        if  let vc = CustomUIDocumentViewController(forPath: "rk.pdf") {
            self.navigationController?.pushViewController(vc, animated: true)
        }
        
    }

看效果

IMG_3729.PNG
IMG_3730.PNG

最后 还有很多功能 自己去探索吧!!!!!

上一篇 下一篇

猜你喜欢

热点阅读