2017-10-16 43 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

希望幫助別人!