2017-10-16 45 views
9

我试图与ionic/cordova plugin here一起使用。DocumentViewer未与Ionic 3配合使用

所以我把这个代码在我的网页:

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页面:

<ion-content> 
    <button ion-button round (click)="showDocument()"> 
    Read 
    </button> 
</ion-content> 

但我不能看到任何模拟器(因为它无法在浏览器上运行它)

离子信息有:

enter image description here

UPDATE

这是我与我的设备和铬devtools调试时:

enter image description here

更新2

我曾尝试以绝对路径工作,但我有空值,我hav E制备这些变化:

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) 

但是看看我有:

enter image description here

+0

控制台中的任何错误使用[远程调试](https://developers.google.com/web/tools/chrome-devtools/remote-debugging/)? –

+0

其实我对远程调试没有太多的想法。我将看到如何使用它 –

+0

@HoussemBdr是您的点击触发器? – Webruster

回答

1

这并不直接回答你的问题,但对于获得PDF文件显示解决方法。

我在阅读PDF时遇到了很多插件问题,所以我最终只使用一个名为PDF.js的Mozilla项目在Android平台上直接在浏览器中呈现PDF,而在iOS上它们本身在浏览器中显示。为了像查看器一样处理它,与我的其他应用程序分开处理,我使用了in app browser window

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

希望帮助别人!