【问题标题】:how to open an Offline pdf in ionic 2 application in adobe reader如何在 adobe reader 的 ionic 2 应用程序中打开离线 pdf
【发布时间】:2017-09-11 09:40:45
【问题描述】:

尝试使用以下代码在 ionic 2 应用程序中打开离线 pdf,但代码是在 smartdox 查看器而不是 adobe reader 中打开 pdf 文件,我如何在此处默认设置 adobe reader 以使 pdf 正常工作。提前致谢。

open()
  {
  const options: DocumentViewerOptions = {
  title: 'My PDF'
  }
  this.document.viewDocument('file:///android_asset/www/assets/test.pdf', 'application/pdf', options)
}

【问题讨论】:

  • 你找到答案了吗?

标签: pdf ionic2 offline documentviewer


【解决方案1】:

不知道你是否解决了这个问题,但这是为我解决问题的方法:

确保您使用的是最新版本的文档查看器插件。

open() {
  const options: DocumentViewerOptions = {
    title: 'My PDF',
    openWith: { enabled: true }, //this will allow you to open the document with an external application
    // any more options
  };
  this.document.viewDocument('file:///android_asset/www/assets/test.pdf', 'application/pdf', options);
}

@rj7 代码的问题在于他在应该是嵌套对象的地方添加了一个函数。有关可以拉入此函数的选项的更多信息,请参阅以下 URL:https://github.com/sitewaerts/cordova-plugin-document-viewer

希望对未来陷入困境的人有所帮助。

【讨论】:

    【解决方案2】:

    试试下面的 openWith(),

    open()
      {
      const options: DocumentViewerOptions = {
      title: 'My PDF',
      openWith() {
        enabled: true
       }
      }
      this.document.viewDocument('file:///android_asset/www/assets/test.pdf', 'application/pdf', options)
    }
    

    【讨论】:

    • 错误:输入'{标题:字符串; openWith(): 无效; }' 不可分配给类型 'DocumentViewerOptions'。属性“openWith”的类型不兼容。类型 '() => void' 不可分配给类型 '{ enabled: boolean; }'。类型“() => void”中缺少属性“启用”。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-10
    • 2017-01-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多