Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
881 views
in Technique[技术] by (71.8m points)

ios - How to open Acrobat Reader to read pdf file?

I have many files in .pdf format. I'm display the names of the files in a collection view. Now in the didSelectItemAtIndex method, I want to open Acrobat Reader to open the pdf files. How do I implement this ? Also does Acrobat Reader have an URL Scheme so that I can detect whether the app is on the phone ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is the app schema for Adobe reader :

com.adobe.Adobe-Reader

In Swift, you can do the following :

           var docController: UIDocumentInteractionController?
    if let path = Bundle.main.path(forResource: "PDF-NAME", ofType: "pdf") {
            let targetURL = NSURL.fileURL(withPath: path)
            docController = UIDocumentInteractionController(url: targetURL)
            let url = NSURL(string:"com.adobe.Adobe-Reader:");
            if UIApplication.shared.canOpenURL(url! as URL) {
                docController!.presentOpenInMenu(from: .zero, in: self.view, animated: true)
                print("Adobe-Reader")
            }else{
                print("Adobe-Reader is not installed")
            }
    }

And add below app schemas in plist.

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>com.adobe.Adobe-Reader</string>
</array>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...