1. GitHub : https://github.com/mozilla/pdf.js

  2. 官网 : https://mozilla.github.io/pdf.js/

  3. demo: https://mozilla.github.io/pdf.js/web/viewer.html

  4. 兼容ie的最新版 : 2.7.570

  5. 解压后放在 static/pdf目录下,使用iframe方式引入

    1
    2
    3
    4
    5
    6
    7
    <iframe
    :src="`./static/pdf/web/viewer.html?file=${pdfUrl}`"
    class="pdf-window"
    width="100%"
    height="100%"
    frameborder="0"
    ></iframe>
  6. 解决电子签章不显示的问题

    • 2.5.207 : 批注掉build/pdf.worker.js文件中_this3.setFlags(_util.AnnotationFlag.HIDDEN);
    • 2.9.359之后的版本: 已经支持了显示电子签章,直接使用
  7. 隐藏界面上的一些按钮 : 修改 web/viewer.js文件中webViewerInitialized方法 在前面添加

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    appConfig.toolbar.presentationModeButton.hidden = true;
    appConfig.toolbar.openFile.hidden = true;
    appConfig.secondaryToolbar.openFileButton.hidden = true;
    appConfig.toolbar.print.hidden = true;
    appConfig.secondaryToolbar.printButton.hidden = true;
    appConfig.toolbar.download.hidden = true;
    appConfig.secondaryToolbar.downloadButton.hidden = true;
    appConfig.toolbar.viewBookmark.hidden = true;
    appConfig.secondaryToolbar.viewBookmarkButton.hidden = true;
    appConfig.secondaryToolbar.toggleButton.hidden = true;
    appConfig.findBar.toggleButton.hidden = true;
    .....