Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

disable pdf download javascript

(function($) {
    $(document).ready(function() {
        var params = window.location.search.substring(1).split("&");
        var disabledownload = false;
        var disableprint = false;
        var disabletext = false;
        var disabledoc = false;
        var disableopen = true;
        for (var i = 0; i < params.length; i++) {
            var value = params[i].split("=");
            if (value && value.length == 2)
                if (value[0] == "disabledownload" && value[1] == 1) disabledownload = 1;
                else if (value[0] == "disableprint" && value[1] == 1) disableprint = 1;
            else if (value[0] == "disabletext" && value[1] == 1) disabletext = 1;
            else if (value[0] == "disabledoc" && value[1] ==
                1) disabledoc = 1
        }
        var extracss = "";
        if (disabledownload) extracss += " .download {display:none!important;}";
        if (disableprint) extracss += " .print {display:none!important;}";
        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;}";
        if (disabledoc) extracss += " #documentProperties {display:none !important;}";
        if (disableopen) extracss += " #openFile { display:none!important;}";
        if (disableopen) extracss += " #secondaryOpenFile { display:none!important;}";
        if (extracss) {
            var style = document.createElement("style");
            style.type = "text/css";
            style.innerHTML = extracss;
            document.getElementsByTagName("head")[0].appendChild(style)
        }
        $(document).bind("pagerendered", function(e) {
            if (disabledownload) $(".download").remove();
            if (disableprint) $(".print").remove();
            if (disableopen) $("#openFile").remove();
            if (disableopen) $("#secondaryOpenFile").remove();
            if (disabletext) {
                $(".selectTool").remove();
                $(".textLayer").remove();
                if (PDFViewerApplication) PDFViewerApplication.pdfCursorTools.switchTool(1)
            }
            if (disabledoc) {
                $(".documentProperties").prev(".horizontalToolbarSeparator").remove();
                $(".documentProperties").remove()
            }
        })
    })
})(jQuery);
Comment

PREVIOUS NEXT
Code Example
Javascript :: color blur in echart 
Javascript :: jquery split multidimensional array 
Javascript :: how concatenate arrays in es6 
Javascript :: joomla add javascript 
Javascript :: Format Mathjax 
Javascript :: how to swap two variable values in js 
Javascript :: makestyle server side rendering 
Javascript :: TYPING TEXT USING JS1 
Javascript :: javascript events reference 
Javascript :: how to check if a string contains a specific word in javascript 
Javascript :: yup password match 
Javascript :: find minimum length word in a phrase 
Javascript :: Remove the warning for setState on unmounted components in React 
Javascript :: filter last object of recursive array using javascript 
Javascript :: how to read textbox values from html and insert them into tables using java script 
Javascript :: form react js 
Javascript :: android MediaController audio example 
Javascript :: pASS - EXE 
Javascript :: react-native-calendars how to mark selected day 
Javascript :: asyncGenerator 
Javascript :: multiple parameters in url Servlet 
Javascript :: Merge Arrarys of Object of Any size 
Javascript :: angular disabled spec.ts 
Javascript :: change active menu item on page scroll javascript 
Javascript :: react native bottom sheet example 
Javascript :: jq unique by object attribute in list 
Javascript :: __v:0 in my data mongoose 
Javascript :: reference to javascript array 
Javascript :: Return Early Pattern for Functions 
Javascript :: how to make local storage read only site:stackoverflow.com 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =