Is it possible to add a PDF file in the assets folder and then access it within the Ionic 2 application.
Asked
Active
Viewed 3,678 times
2 Answers
1
There are a number of ways to do that.
- InAppBrowser
- Themeable Browser
- Sitewearts Document viewer
- Android Native PDF Viewer
You can find the cordova plugins for all the above situations. Please read below article to see more info.
Git repo: PDFExample

Sampath
- 63,341
- 64
- 307
- 441
-
1Hi using these methods we can download an online pdf and save that and later open it. My requirement is to add the PDF inside the application folder. As soon as you install the app, the PDF will be available in it. No online interactions – Rahul Raj Apr 05 '17 at 06:26
-
@sampath i am trying to use inappbrowser using ionic but i am not able to get the pdf i am getting blank white screen please look at this https://stackoverflow.com/questions/44427319/how-to-open-an-local-pdf-using-inappbrowser/44429700#44429700 – Mohan Gopi Jun 08 '17 at 10:00
0
I use this code and it works for me.
Its need 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)
}

Pratik Gadoya
- 1,420
- 1
- 16
- 27

Rijwandeltax
- 152
- 1
- 13