Resize a div when printing
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/
精彩评论