PDF not opening on some phones (Ionic3)


We are working on an app project with ionic3 for android and having a little issue to show pdfs on some phones.
in .ts the code we have :

import { File } from '@ionic-native/file';
import { DocumentViewer, DocumentViewerOptions } from '@ionic-native/document-viewer';
import { FileTransfer, FileTransferObject } from '@ionic-native/file-transfer';
import { FileOpener } from '@ionic-native/file-opener';
 public pdfDownload(id){
    const url = this.idealParam.api+'analysis/resultat/?id='+id+'&iduser='+this.id+'.pdf';
    const fileTransfer: FileTransferObject = this.transfer.create();
    fileTransfer.download(url,this.file.dataDirectory  + 'file.pdf').then((entry) => {
    console.log('download complete: ' + entry.toURL());
    this.fileOpener.open(entry.toURL(), 'application/pdf')
    .then(() => {
      this.service.setAnalyseLu(this.id,id, this.groupe)
        .subscribe(data => {})
  .catch(e => console.log('Error opening file', e));

In the html we have :

        <ion-item style="border:0px;" (click)="pdfDownload(obj.Analysis.id)">
          <ion-thumbnail item-start>
            <img src="assets/imgs/pdf.png">
          <h2><i class="icon icon-cursor-pointer" style="-webkit-text-stroke-color: #5b8e14;"></i> File</h2>
          <p>Click here</p>

On my Samsung A5 2017 Android 7.0 it works like a charm (It asks me what program to use and all of them worked fine)
but on my Galaxy S4 Android 5.0.1 I have an error telling me wrong path to file (InFrench: Le chemin d’accès au document est incorrect) All programs didn’t open the file.
Any help please ?
Thank you a lot


Hello my friends
I really hope that someone will help me as I’m blocked since days on this matter
Here are some extra info :

ionic info

cli packages: (C:\Users\ASUS\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.9
    Cordova Platforms  : android 7.0.0 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2


    Node : v8.11.3
    npm  : 5.6.0
    OS   : Windows 10

Environment Variables:

    ANDROID_HOME : not set


    backend : pro

Thank you a lot



if nobody has an better idea, then try targeting your app to api 21 (Android 5).

If it is then working, then it has maybe something todo with changes of fileaccess between these android versions that needs further investigation in this direction.

Best regards, anna-liebt


Thank you anna_liebt
Unfortunately Google Play Store didn’t accept targetSdkVersion under 23 and this didn’t resolve the problem
Don’t you think that the file path maybe has to be changed ?
this.file.dataDirectory + 'file.pdf'


I have no particular idea, why this happens. But maybe it has something to do with changes of file access between this 2 android versions. If you retarget your system to api 21 and then it will works on your samsung, then you can look further in this direction. https://developer.android.com/about/versions/nougat/android-7.0-changes

Otherwise, hmmm, post all strings, joined strings you made. Maybe somebody see something.

Best regards, anna-liebt


Hello @anna_liebt
Thank you a lot
I tryed with level 21 changing the line in AndroidManifest.xml to :
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" />
After that I sent the app to the phone (Galaxy S4 Android 5.0.1) and the results was the same unfortunately
I will post joined strings we made
Thank you for your precious help


There is no way to do it
I will be happy if an admin delete this topic as it has no solution



are all pdf files affected or could only your pdf file not opend by all pdf readers on your phone.
Are all folders affected or are you able to open a well known, not by your code handled, standard pdf file from a other folder?

Best regards, anna-liebt


Incase of Android 7, changed the following line in my androidmanifest.xml file and it work:

<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="24" />


<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />