Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

FileOpener and DocumentViewer are not working

$
0
0

@OliverPrimo wrote:

Hello Everyone,

I created a function that will get the PDF Blob file from the server and save it to phone’s storage. Now, I want the user to be able to open it once the file was downloaded. I tried using FileOpener (cordova-plugin-file-opener2) but it didn’t work without showing any errors. Same with trying the DocumentViewer (cordova-plugin-document-viewer) but it also didn’t work without showing any errors. I am testing the app on an actual mobile phone and tried to alert the error if there’s any since the moblie phone have no consoles but it doesn’t display any errors. I don’t know how to make it work or if there is anything that I can use aside from FileOpener and DocumentViewer. Btw, here are my codes.

FileOpener

              this.fileOpener.open(filePath, 'application/pdf').then(response => {
                this.toastSrvc.presentToast(response);
              })
              .catch(error => {
                this.alertCtrl.create({
                  title: 'Error opening the file',
                  message: error,
                  buttons: [
                    {
                      text: 'Close',
                      role: 'cancel',
                      handler: () => {
                        console.log('Alert Closed!');
                      }
                    }
                  ]
                }).present();
              });

DocumentViewer

this.documentViewer.viewDocument(filePath + 'Vidalia/' + fileName, 'application/pdf', options, this.onShow, this.onClose, this.onMissingApp, this.onError);

  onShow() {
    this.alertCtrl.create({
      message: 'Show'
    }).present();
  }

  onError() {
    this.alertCtrl.create({
      message: 'Error'
    }).present();
  }

  onMissingApp() {
    this.alertCtrl.create({
      message: 'Missing App'
    }).present();
  }

  onClose(){
    this.alertCtrl.create({
      message: 'Close'
    }).present();
  }

I hope someone can help me with this. Thank you in advance :slight_smile:

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>