【问题标题】:How can I display a pdf with pdftron using npm如何使用 npm 使用 pdftron 显示 pdf
【发布时间】:2021-03-01 22:42:25
【问题描述】:
  1. pdftron/webviewer 已安装

     "dependencies": {
         "@pdftron/webviewer": "^7.3.0",
         "body-parser": "^1.19.0",
         "express": "^4.17.1",
         "mongoose": "^5.9.7",
         "nodemon": "^2.0.2",
         "pug": "^2.0.4"
     }
    
  2. Webviewer 静态文件已复制到公用文件夹

  3. index.html 文件中的 JavaScript 尝试加载 pdf

    欢迎使用网络浏览器 从“@/webviewer”导入 WebViewer
         WebViewer({
             path: '/webviewer',
             initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/demo-annotated.pdf'
         }, 
         document.getElementById('viewer')).then(instance => {})    
      </script>
    
  4. pdf文件不显示,代码有什么问题?

【问题讨论】:

  • 嗨。是否可以显示您的控制台和网络选项卡的屏幕截图?是否也可以提供指向您的存储库的链接?
  • 这里是 [repository] ​​(github.com/ashe-senkatuuka/pdf-display) @Ryan

标签: javascript pdf npm client-side pdftron


【解决方案1】:

感谢您分享指向您的存储库的链接。

根据本指南:https://www.pdftron.com/documentation/web/get-started/manually/

请尝试执行以下操作:

  1. 请将 pdftron webviewer 节点模块中的 webviewer.min.js 复制并粘贴到 /public/webviewer

  2. 在您的 custom.js 中,请删除从 webviewer 导入的行

  3. 在您的 index.html 中,请在调用您的 custom.js 文件之前添加此脚本标记: &lt;script src='./webviewer/webviewer.min.js'&gt;&lt;/script&gt;

编辑: 当我加载您的应用程序时,我注意到网络选项卡上有一个 404,这让我认为库的设置没有正确集成。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-04
    • 1970-01-01
    • 2022-01-14
    • 1970-01-01
    相关资源
    最近更新 更多