本文介绍了window.print的字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我使用window.print打印gridview内容,但我无法更改字体大小,这是我使用的代码: function printGrid(){ var gridData = document.getElementById('<%= gvList.ClientID%>'); var windowUrl =''; //为gridview设置打印文档名 var uniqueName = new Date(); var windowName ='Print_'+ uniqueName.getTime(); var prtWindow = window.open(windowUrl,windowName,'left = 0,top = 0,right = 0,bottom = 0,width = screen.width,height = screen.height,margin = 0,0, 0,0' ); prtWindow.document.write('< html>< head>< font size =5> TITLE< / font>< / head>'); prtWindow.document.write('< body style =background:none!important; font-size:10pt!important>'); prtWindow.document.write(gridData.outerHTML); prtWindow.document.write('< / body>< / html>'); prtWindow.document.close(); prtWindow.focus(); prtWindow.print(); prtWindow.close(); } 此代码有什么问题?解决方案 i use a window.print to print gridview content, but i can't change the font size, here is the code i used:function printGrid() { var gridData = document.getElementById('<%= gvList.ClientID %>'); var windowUrl = ' '; //set print document name for gridview var uniqueName = new Date(); var windowName = 'Print_' + uniqueName.getTime(); var prtWindow = window.open(windowUrl, windowName, 'left=0,top=0,right=0,bottom=0,width=screen.width,height=screen.height,margin=0,0,0,0'); prtWindow.document.write('<html><head><font size="5">TITLE</font></head>'); prtWindow.document.write('<body style="background:none !important; font-size:10pt !important">'); prtWindow.document.write(gridData.outerHTML); prtWindow.document.write('</body></html>'); prtWindow.document.close(); prtWindow.focus(); prtWindow.print(); prtWindow.close(); }anything wrong in this code? 解决方案 这篇关于window.print的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-04 05:21