简体   繁体   English

如何在Ionic 2中打开assets文件夹中包含的PDF文件?

[英]How to open a PDF file included in assets folder in Ionic 2?

是否可以在assets文件夹中添加PDF文件,然后在Ionic 2应用程序中访问它。

There are a number of ways to do that. 有很多方法可以做到这一点。

  1. InAppBrowser InAppBrowser
  2. Themeable Browser 主题浏览器
  3. Sitewearts Document viewer Sitewearts文档查看器
  4. Android Native PDF Viewer Android Native PDF Viewer

You can find the cordova plugins for all the above situations. 您可以找到适用于上述所有情况的cordova插件。 Please read below article to see more info. 请阅读以下文章以了解更多信息。

Opening PDF Files In Ionic 2 在Ionic中打开PDF文件2

Git repo: PDFExample Git repo: PDFExample

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)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM