Search code examples
androidpdfphonegapinappbrowserandroid-8.1-oreo

How to display a PDF from a phonegap app in Android 8


I manage to display PDF with phonegap inappbrowser in ios and Android 6 but not Android 8.

Here is the code :

      if (platform !== 'Android') {
        var ref = window.open(
          decodeURI(pdf.filepath),
          '_blank',
          `location=no,closebuttoncaption=Close,enableViewportScale=yes`
        )
      } else {
        var ref = window.open(
          decodeURI(pdf.filepath),
          '_system',
          `location=no,closebuttoncaption=Close,enableViewportScale=yes`
        )
      }

The button that trigger this code open a new window, but she’s remains empty. I tried with a wrong path, it shows an error so it’s not a path problem.

Any Idea ?


Solution

  • Finaly I managed to display PDF on Android > 6. It’s not possible to display PDF through inappbrowser for Android > 6 (2 fulltime days of testing and googling...).

    I used cordova-plugin-file-opener2. But what’s important to know (I didn’t until yesterday), you can’t test plugins via "phonegap serve" + phonegap app on device !! You need to build the apk, install it and then test it. This important point make me loose my nerves on various plugins...

    That’s all.