locked
Silent Print From Client side IE RRS feed

  • Question

  • Hi,

    I tried print pdf from browser via javascript.

    it prints with dialog box . i tried to skip this dialog box but failed in doing so.

    i tried several codes like

    1 -- // this also opens dialog box

      

    function print1()
    {
    if (navigator.appname == "microsoft internet explore")
    {
    var printcommand = '<object id="printcommandobject" width=0 height=0 classid="clsid:8856f961-340a-11d0-a96b-00c04fd705a2"></object>';
    document.body.insertadjacenthtml('beforeend', printcommand);
     document.all.printcommandobject.execwb(6,-1);
    printcommandobject.outerhtml = "";
    }
    else {
    window.print();
    }
    }
    </script>

    <button onclick=print1()>Try it</button>

    2-this is second code which i tried

    <script>
    function btn_print_onclick() {
      factory.printing.header = "This is MeadCo";
      factory.printing.footer = "Printing by ScriptX";
      factory.printing.portrait = false;
      factory.printing.leftMargin = 1.0;
      factory.printing.topMargin = 1.0;
      factory.printing.rightMargin = 1.0;
      factory.printing.bottomMargin = 1.0;
      factory.printing.Print(false);
    }
    </script>

        
    </head>
    <body>
       <button onclick="btn_print_onclick()">Print report</button>
    </body>

    3 - also tried some links but they also didn't work for me

    http://forums.asp.net/t/1364879.aspx?Avoid+Print+dialog+box+while+printing+webpage

    http://www.webdeveloper.com/forum/showthread.php?174029.html

    http://justtalkaboutweb.com/2008/05/09/javascript-print-bypass-printer-dialog-in-ie-and-firefox/

    http://scriptx.meadroid.com/community-support/community-forum/general/2014/1/the-problem-of-scriptx-in-ie8.aspx


    http://codeverge.com/asp.net.getting-started/avoid-print-dialog-box-while-printing/726740

    https://gist.github.com/cchitsiang/7349218

    http://www.codeproject.com/Questions/784656/Printing-in-one-click-I-dont-want-print-setup-dial

    any help will be appreciated.

    Thanks

    Sushil

    Tuesday, July 28, 2015 7:00 AM