To run the example project, clone the repo, and run pod install
from the Example directory first.
- iOS 13.0+
- Xcode 11.0+
PKDocumentViewer is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'PKDocumentViewer'
//implement UIDocumentInteractionControllerDelegate
class ViewController: UIViewController,UIDocumentInteractionControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Setup delegates
PKDocumentViewer.shared.setUpDelegates(self)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func viewPDFButtonTapped(_ sender: Any) {
// Call to view pdf
PKDocumentViewer.shared.viewPdf(urlPath: "http://www.pdf995.com/samples/pdf.pdf", screenTitle: "Tesing Document")
}
// when a document interaction controller needs a view controller for presenting a document preview.
// use this fuction for preview
func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
return self.navigationController ?? UIViewController()
}
}
Pawan Kumar iOS Developer, [email protected],https://pawankumar.cf/
PKDocumentViewer is available under the MIT license. See the LICENSE file for more info.