How to open PDF file included in assets folder in Ionic 2?

Is it possible to add a PDF file to assets folder and then access it in Ionic 2 app.

+3


source to share


2 answers


There are several ways to do this.

  • InAppBrowser
  • Thematic browser
  • Viewing documents in Sitewearts format
  • Built-in PDF viewer

You can find cordova plugins for all of the above situations. Please read the article below to find out more.



Opening PDF files in Ionic 2

Git repo: PDFExample

+1


source


I am using this code and it works for me.

He needs a plugin.



showDocument(){
    const options: DocumentViewerOptions = {
        title: 'My PDF'
    }
    const imgeLocation = `${cordova.file.applicationDirectory}www/assets/imgs/${'Jainbhajan-Jeevan-Saar-By-Nirmal-Gangwal-1-ilovepdf-compressed (1).pdf'}`;
    this.document.viewDocument(imgeLocation, 'application/pdf', options)
}

      

0


source







All Articles