# How to Open PDF file inside dataDirectory

**URL:** <https://forum.ionicframework.com/t/how-to-open-pdf-file-inside-datadirectory/88527>\
**Category:** ionic-v3\
**Created:** [May 2, 2017, 2:40am UTC](https://forum.ionicframework.com/t/how-to-open-pdf-file-inside-datadirectory/88527 "2017-05-02T02:40:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![leah\_fuentes](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/leah_fuentes/32/109150_2.png) [@leah\_fuentes](https://forum.ionicframework.com/u/leah_fuentes)\
**Post date:** [May 2, 2017, 2:40am UTC](https://forum.ionicframework.com/t/how-to-open-pdf-file-inside-datadirectory/88527/1 "2017-05-02T02:40:16Z")

</div>

The scenario was download documents and save to dataDirectory.  
After that, the user will be able to view it on the app.

I was trying to use InAppBrowser but only gives me a blank screen  
Below is my current code.

```auto
openSource(url : string) {
   this.platform.ready().then(() => {
        new InAppBrowser(url, "_blank", 'location=yes,clearcache=no,toolbar=no,closebuttoncaption=Close,hardwareback=no');
    });
}

```

I also tried to use “\_system”, it let me choose what application to use to open the file but after that, it says “Cannot read/open file” .

I tried to test other file types like png and jpg using the above code to check if it does really save on the path I have provided and works fine.I was able to view the image.

I also tried to open a document that gets the file from the internet and it just give me blank view. I guess my code doesn’t really work for documents like Pdf.

Could anyone help me, how can I open/view documents I save on dataDirectory.  
Thank you so much guys.

---

<div class="post-metadata">

**Author:** ![peelfresh](https://avatars.discourse-cdn.com/v4/letter/p/ee59a6/32.png) [@peelfresh](https://forum.ionicframework.com/u/peelfresh)\
**Post date:** [May 2, 2017, 3:24am UTC](https://forum.ionicframework.com/t/how-to-open-pdf-file-inside-datadirectory/88527/2 "2017-05-02T03:24:37Z")

</div>

Try file opener plugin. But it requires the device to have pdf viewer installed.

> **[Ionic Framework](https://ionicframework.com/docs/native/file-opener/)**
>
> Ionic is the app platform for web developers. Build amazing mobile, web, and desktop apps all with one shared code base and open web standards

---

<div class="post-metadata">

**Author:** ![leah\_fuentes](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/leah_fuentes/32/109150_2.png) [@leah\_fuentes](https://forum.ionicframework.com/u/leah_fuentes)\
**Post date:** [May 2, 2017, 6:44am UTC](https://forum.ionicframework.com/t/how-to-open-pdf-file-inside-datadirectory/88527/3 "2017-05-02T06:44:23Z")

</div>

Helo, yes I have tried this as well. However, I keep on getting a response error that plugin is not installed even though I have a pdf viewer on my device.

See Below Code for reference.

```auto
openSource(url : string,filenamme) {

var ext = filenamme.substr(filenamme.lastIndexOf('.') + 1);
var mime = this.appctr.getFileMIME('.'+ext);

    this.platform.ready().then(() => {

        FileOpener.open(url,mime.mim).then((sucesss)=> {
          alert(sucesss);
        }).catch((err)=>{
             alert(err);
        });
    });
}

//code for getting file mime type

  getFileMIME(ext){
    for(let i of this.Mimeobject()){
   
      if(i.id === ext){
        return i;
      }
    }

   
  }

//test mimeobject

  Mimeobject(){
    var mime = [];
    mime=[
          {'id':'.3dm', 'mim': 'x-world/x-3dmf'},
          {'id':'.pdf', 'mim': 'application/pdf'},
          {'id':'.doc', 'mim': 'application/msword'},
          {'id':'.png', 'mim': 'image/png'},
        ]
  
    return mime;
  }

```

---

<div class="post-metadata">

**Author:** ![leah\_fuentes](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/leah_fuentes/32/109150_2.png) [@leah\_fuentes](https://forum.ionicframework.com/u/leah_fuentes)\
**Post date:** [May 5, 2017, 7:15am UTC](https://forum.ionicframework.com/t/how-to-open-pdf-file-inside-datadirectory/88527/4 "2017-05-05T07:15:55Z")

</div>

My updates on PDF viewer.

Though I haven’t solved to make file opener plugin to work on my current project. I just tried to use the [ng2-pdf-viewer](https://www.npmjs.com/package/ng2-pdf-viewer) instead, and bwalaahhh is a success.

However, my goal is to open different document file whether pdf, xls, docx, png etc. 😅  
Looking for an available plugin for this, or will still try to make file opener plugin working? (But I am stuck 😱 )

Anyone who have a solution, I would really love to know.  
Would appreciate it much.

Thank you in advance guys.
