无法使用DocumentViewer ionic 4打开PDF网址

时间:2019-05-29 15:43:22

标签: pdf ionic-framework ionic4

我有一个pdf URL,我想使用DocumentViewer打开它。当我运行代码时:

this._document.viewDocument(pdfUrl, 'application/pdf', options);

它没有打开PDF。我尝试将PDF下载到手机上,然后将其打开。请在下面找到代码:

transfer.download(downloadUrl, filename).then(entry => {
      const url = entry.toURL();
      if (this._plt.is('ios')) {
        this._document.viewDocument(pdfUrl, 'application/pdf', options);
      } else {
        this._fileOpener.open(pdfUrl, 'application/pdf')
          .then(() => console.log('File is opened'))
          .catch(e => this.presentAlert('Error opening file', e));
      }
    });

我的PDF中有表格和图片。当我运行上述代码时,无法在PDF中看到HTML5表格。

我需要有关如何直接使用DocumentViewer打开PDF URL的帮助。

注意::我在StackOverflow上看到了几则建议使用InAppBrowser的帖子。我有一个需要将其显示为PDF的要求。

1 个答案:

答案 0 :(得分:0)

我已经读过https://github.com/sitewaerts/cordova-plugin-document-viewer

在android中:由于muPDF中的许可证限制,该插件会分派到基于muPDF的单独的(免费)查看器应用程序。如果尚未安装查看器应用,则可以将用户重定向到Google Play应用商店。

https://play.google.com/store/apps/details?id=de.sitewaerts.cleverdox.viewer

您可以使用其他pdf插件,例如

https://github.com/vadimdez/ng2-pdf-viewer/

希望这会有所帮助