[英]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.
我正在使用CallPrint JavaScript方法来打印div。 I need to add a header and also re-size the div to fit the page better.
我需要添加一个标题,并重新调整div的大小以更好地适应页面。 Here is the CallPrint method.
这是CallPrint方法。
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. 相反,您应该在html文件的顶部有
<link rel="stylesheet" type="text/css" media="print" href="print.css" />
,并通过提供cutom CSS来更改该元素用于打印。
Here for more reading : http://www.alistapart.com/articles/goingtoprint/ 这里有更多阅读: http : //www.alistapart.com/articles/goingtoprint/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.