我试着和离子/科尔多瓦插件一起工作。
所以我把这段代码放在我的页面里:
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>但是我看不到模拟器中的任何东西(因为不可能在浏览器上运行它)
Ionic信息在那里:

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

更新2
我尝试过使用绝对路径,但我获得了null值,我做了以下更改:
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)但看看我有什么:

发布于 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
希望这能帮到别人!
https://stackoverflow.com/questions/46770130
复制相似问题