开发者

Resize a div when printing

开发者 https://www.devze.com 2023-04-02 16:03 出处:网络
I have a div of a gridview that needs to be printed.I am using a CallPrint JavaScript method to print the div.I开发者_如何学C need to add a header and also re-size the div to fit the page better.Here

I have a div of a gridview that needs to be printed. I am using a CallPrint JavaScript method to print the div. I开发者_如何学C need to add a header and also re-size the div to fit the page better. Here is the CallPrint method.

    function CallPrint(strid) {
        var prtContent = document.getElementById(strid);
        var WinPrint =
        window.open('', '', 'letf=0,top=0,width=800,height=550,toolbar=0,scrollbars=0,status=0');
        WinPrint.document.write(prtContent.innerHTML);
        WinPrint.document.close();
        WinPrint.focus();
        WinPrint.print();
        WinPrint.close();
        prtContent.innerHTML = strOldOne;
    }    //Generating Pop-up Print Preview page    


This is not the way to go.

Instead you should have something like <link rel="stylesheet" type="text/css" media="print" href="print.css" /> at the top of your html file, and change that element by providing cutom CSS for the print.

Here for more reading : http://www.alistapart.com/articles/goingtoprint/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号