PDF.js 调试记录 作者: Hogwarts 发布于: 2026-01-20 更新于: 2026-01-24 分类: 默认分类 项目地址 `https://github.com/mozilla/pdf.js` 以下设置仅能骗骗小白。亲测让Gemini写一个html的限制网页比调试PDF.js好太多了。 #1.禁用鼠标右键弹出、禁止复制粘贴 在viewer.html中,body内容最后加入 #2.隐藏下载和打印按钮 打开 viewer.html 文件,找到 `` 标签内的 ` 可隐藏按钮很多,按F12看title的值即可找到。 #3.禁用快捷键 禁用ctrl+p、ctrl+s快捷键。 修改打开 viewer.js文件,注释掉以下几项。 //eventBus.on('beforeprint', _boundEvents.beforePrint); //eventBus.on('afterprint', _boundEvents.afterPrint); //eventBus.on('print', webViewerPrint); //eventBus.on('download', webViewerDownload); //eventBus.off('print', webViewerPrint); //eventBus.off('download', webViewerDownload); //PDFViewerApplication.download(); //window.print(); 具体是哪几个起作用的还没弄明白,因为Firefox浏览器缓存设置因为升级默认打开了。一直调不好,最后清理缓存就好了。 还有说搜索“83”,将下列注释掉。 //if (cmd === 1 || cmd === 8) { //switch (evt.keyCode) { //case 83: //PDFViewerApplication.download(); //handled = true; //break; //} //} #4.调试的版本为老版本,新版本还未调试。 #5.参考 [pdf.js 组件中预览 pdf 右上角的下载及打印按钮怎么隐藏](http://119.96.220.140:9099/article/1688005276164 "pdf.js 组件中预览 pdf 右上角的下载及打印按钮怎么隐藏") [Vue pdf.js在线预览添加水印并禁用打印功能](https://juejin.cn/post/7039607610793803789 "Vue pdf.js在线预览添加水印并禁用打印功能") [pdf.js禁止下载功能](https://blog.csdn.net/liuying93/article/details/83410405 "pdf.js禁止下载功能") 标签: pdf