locked
Print pdf by its bytearray embeded in javascripts RRS feed

  • Question

  • Hi,

    I want to print a pdf document from javascript but i don't want tro open this in new browser.

    I know how to print <div> tag element but unable to do for pdf file

    i used this code for direct print

    <!DOCTYPE html>
    <html>
    <head>
    <script>
    function printContent(el){
        var restorepage = document.body.innerHTML;
        var printcontent = document.getElementById(el).innerHTML;
        document.body.innerHTML = printcontent;
        window.print();
        document.body.innerHTML = restorepage;
    }
    function printTrigger(elementId) {
    debugger;
        var getMyFrame = document.getElementById(elementId);
        getMyFrame.focus();
        getMyFrame.contentWindow.print();
    }
    </script>
    </head>
    <body>
    <h1>My page</h1>
    <div id="div1">DIV 1 content...</div>
    <button onclick="printContent('div1')">Print Content1</button>
    <div id="div2">DIV 2 content...</div>
    <button onclick="printContent('div2')">Print Content2</button>
    <button onclick="printContent('exPDF')">Print Content3</button>
    <p id="pr"><object id="exPDF" type="application/pdf" data="qryGMSiteCodes_Invalidsitecodereport.pdf" width="100%" height="500"/></p>
    </body>
    </html>

    this code works for  button Print Content1,Print Content2 but it does not works for Print Content3 button.

    can anyone help me about what i am doing wrong for pdf printing.

    thanks,

    Sushil


    Wednesday, July 29, 2015 3:39 PM