disable pdf download javascript

Solutions on MaxInterview for disable pdf download javascript by the best coders in the world

showing results for - "disable pdf download javascript"
Valery
13 Jun 2019
1(function($) {
2    $(document).ready(function() {
3        var params = window.location.search.substring(1).split("&");
4        var disabledownload = false;
5        var disableprint = false;
6        var disabletext = false;
7        var disabledoc = false;
8        var disableopen = true;
9        for (var i = 0; i < params.length; i++) {
10            var value = params[i].split("=");
11            if (value && value.length == 2)
12                if (value[0] == "disabledownload" && value[1] == 1) disabledownload = 1;
13                else if (value[0] == "disableprint" && value[1] == 1) disableprint = 1;
14            else if (value[0] == "disabletext" && value[1] == 1) disabletext = 1;
15            else if (value[0] == "disabledoc" && value[1] ==
16                1) disabledoc = 1
17        }
18        var extracss = "";
19        if (disabledownload) extracss += " .download {display:none!important;}";
20        if (disableprint) extracss += " .print {display:none!important;}";
21        if (disabletext) extracss += " .textLayer {-webkit-touch-callout: none !important; -webkit-user-select: none !important; -khtml-user-select: none !important; -moz-user-select: none !important; -ms-user-select: none !important; user-select: none !important;} .selectTool { display: none !important;}";
22        if (disabledoc) extracss += " #documentProperties {display:none !important;}";
23        if (disableopen) extracss += " #openFile { display:none!important;}";
24        if (disableopen) extracss += " #secondaryOpenFile { display:none!important;}";
25        if (extracss) {
26            var style = document.createElement("style");
27            style.type = "text/css";
28            style.innerHTML = extracss;
29            document.getElementsByTagName("head")[0].appendChild(style)
30        }
31        $(document).bind("pagerendered", function(e) {
32            if (disabledownload) $(".download").remove();
33            if (disableprint) $(".print").remove();
34            if (disableopen) $("#openFile").remove();
35            if (disableopen) $("#secondaryOpenFile").remove();
36            if (disabletext) {
37                $(".selectTool").remove();
38                $(".textLayer").remove();
39                if (PDFViewerApplication) PDFViewerApplication.pdfCursorTools.switchTool(1)
40            }
41            if (disabledoc) {
42                $(".documentProperties").prev(".horizontalToolbarSeparator").remove();
43                $(".documentProperties").remove()
44            }
45        })
46    })
47})(jQuery);
48
similar questions
queries leading to this page
disable pdf download javascript