0

In these questions (question 1 and question 2) it was answered how to use the url scheme or how to use the document interaction controller to display a pdf. On the first question there is a discussion about using the correct path to pass to the open function, and it seems it is posible despite other threads saying this functionality is not yet implemented (here) i know it is old but it wasn't answered.

So what i am trying to do is to open a file that is in my app's document folder. I have set to true the properties LSSupportsOpeningDocumentsInPlace and UIFileSharingEnabled so adobe reader is able to open my files from my documents folder instead of creating a new copy, and that works well with the document interaction controller, but if a try to open it with the open command it just opens the adobe reader app without a file.

 override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    let fileURL = list[indexPath.row]

    // Option 1 Open it using Document Interaction Controller
    //let controller = UIDocumentInteractionController(url: fileURL)
    //controller.delegate = self
    //controller.presentPreview(animated: true)

    // Option 2 Use URL Scheme
    //let filePath = "com.adobe.adobe-reader://" + fileURL.absoluteString
    //let filePath = "com.adobe.adobe-reader://" + String(fileURL.absoluteString.dropFirst(8))
    let filePath = "com.adobe.adobe-reader://" + fileURL.path
    UIApplication.shared.open(URL(string: filePath)!)
}

This is the path i am passing to the open method

"com.adobe.adobe-reader:///var/mobile/Containers/Data/Application/605AC702-F476-4108-8C54-AB2A3E0E2F15/Documents/OoPdfFormExample.pdf"

Any suggestions ? or do you notice something wrong ?

I am targeting iOS 11.2

Javobal
  • 131
  • 1
  • 9
  • You might not be able to pass such a URL unless its shared across apps.. You might have to pass NSData.. – Brandon Jan 10 '18 at 20:40
  • Why don't you display it inside your app using QuickLook? – Leo Dabus Jan 10 '18 at 20:50
  • 1
    `String(fileURL.absoluteString.dropFirst(8))` ??? if you don't what your fileURL scheme just get the `path` property – Leo Dabus Jan 10 '18 at 20:53
  • @LeoDabus about QuickLook that works very well, but i want to fill some pdf forms and sign them as well. That was just one of my attempts, i am using the path property in the third line. – Javobal Jan 10 '18 at 20:53

0 Answers0