首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >DocumentViewer不使用Ionic 3

DocumentViewer不使用Ionic 3
EN

Stack Overflow用户
提问于 2017-10-16 12:16:13
回答 1查看 3.6K关注 0票数 8

我试着和离子/科尔多瓦插件一起工作。

所以我把这段代码放在我的页面里:

代码语言:javascript
复制
  showDocument() {
    var options: DocumentViewerOptions = {
      title: 'A book',
      documentView: { closeLabel: '' },
      navigationView: { closeLabel: '' },
      email: { enabled: true },
      print: { enabled: true },
      openWith: { enabled: true },
      bookmarks: { enabled: true },
      search: { enabled: false },
      autoClose: { onPause: false }
    }
    this.docViewer.viewDocument('assets/arabic.pdf', 'application/pdf', options);
  }

还有一个在html页面中启动它的简单按钮:

代码语言:javascript
复制
<ion-content>
  <button  ion-button round (click)="showDocument()">
    Read
  </button>
</ion-content>

但是我看不到模拟器中的任何东西(因为不可能在浏览器上运行它)

Ionic信息在那里:

更新

在使用我的设备和chrome devtools进行调试时,我会得到这样的结果:

更新2

我尝试过使用绝对路径,但我获得了null值,我做了以下更改:

代码语言:javascript
复制
import { File } from '@ionic-native/file';
declare let cordova: any;
//staff

pdfSrc: string = cordova.file.applicationDirectory + 'assets/arabic.pdf';

//staff
console.log(this.pdfSrc);
this.document.viewDocument(this.pdfSrc, 'application/pdf', options)

但看看我有什么:

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-11-10 17:44:25

这不直接回答您的问题,但是一个解决办法,使PDF显示。

我在读取PDF时遇到了很多插件问题,所以我只使用了一个名为PDF.js的Mozilla项目在安卓平台上直接在浏览器中呈现PDF,而在iOS上,它们是在浏览器中本地显示的。为了像查看器一样处理它,与我的应用程序的其他部分不同,我使用了一个在应用程序浏览器窗口

这里有一些PDF.js的代码示例:http://mozilla.github.io/pdf.js/examples/index.html#interactive-examples

希望这能帮到别人!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46770130

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档