简体   繁体   English

如何禁用 PDF 查看器的打印屏幕选项

[英]How to disable the print screen option for the PDF viewer

We were given a task of disabling the print screen option for a PDF viewer.我们的任务是禁用 PDF 查看器的打印屏幕选项。 I have tried using code but wasn't able to give a blank page either.我曾尝试使用代码,但也无法给出空白页。 Please can someone help me in this..请有人帮我这个..

$(document).ready(function() {
  $(window).keyup(function(e) {
    if (e.keyCode == 44) {
      $("body").hide();
    }
  }); 
}); 

I'm not sure what you actually looking for.我不确定你真正在寻找什么。 But this code will help you to disable the print screen.但是此代码将帮助您禁用打印屏幕。 You can't copy any text from the print screen.您无法从打印屏幕复制任何文本。 I must say this is a very weird task for the beginner.我必须说这对初学者来说是一项非常奇怪的任务。 Please check what is clipboard data if you don't know.如果您不知道,请检查clipboard data是什么。

document.addEventListener("keyup", function (e) {
        var keyCode = e.keyCode ? e.keyCode : e.which;
         if (keyCode == 44) {
                    stopPrintScreen();
         }
       });
    function stopPrintScreen() {
                var inpFld = document.createElement("input");
                inpFld.setAttribute("value", ".");
                inpFld.setAttribute("width", "0");
                inpFld.style.height = "0px";
                inpFld.style.width = "0px";
                inpFld.style.border = "0px";
                document.body.appendChild(inpFld);
                inpFld.select();
                document.execCommand("copy");
                inpFld.remove(inpFld);
     }
     function AccessClipboardData() {
            try {
                 window.clipboardData.setData('text', "Access   Restricted");
                } catch (err) {
               console.log(error)
             }
      }
     setInterval("AccessClipboardData()", 300);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM