网页打印代码
<style media=print>
.Noprint{display:none;}
</style>
<script language="JavaScript">
function dayin(){window.print()}
function dayin1(){try{document.all.WebBrowser.ExecWB(6,6)}catch(e){alert("您的浏览器不支持此功能,需要5.5以上版本")}}
function pageSetup(){try{document.all.WebBrowser.ExecWB(8,1)}catch(e){alert("您的浏览器不支持此功能,需要5.5以上版本")}}
function preView(){try{document.all.WebBrowser.ExecWB(7,1)}catch(e){alert("您的浏览器不支持此功能,需要5.5以上版本")}}
</script>
<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0></OBJECT>
<p>页面打印测试</p>
<p><span class="Noprint">测试1:
<input type=button value=打印 onclick="window.print()">
<INPUT type=button value=打印 onclick="document.execCommand('Print')">
</span>
</p>
<p class="Noprint">测试2:
<input class="Noprint" type=button value=打印 onclick="dayin()">
<input class="Noprint" type=button value=直接打印 onclick="dayin1()">
<input class="Noprint" type=button value=页面设置 onclick="pageSetup()">
<input class="Noprint" type=button value=打印预览 onclick="preView()">
</p>
<style media=print>
.Noprint{display:none;}
</style>
<script language="JavaScript">
function dayin(){window.print()}
function dayin1(){try{document.all.WebBrowser.ExecWB(6,6)}catch(e){alert("您的浏览器不支持此功能,需要5.5以上版本")}}
function pageSetup(){try{document.all.WebBrowser.ExecWB(8,1)}catch(e){alert("您的浏览器不支持此功能,需要5.5以上版本")}}
function preView(){try{document.all.WebBrowser.ExecWB(7,1)}catch(e){alert("您的浏览器不支持此功能,需要5.5以上版本")}}
</script>
<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0></OBJECT>
<p>页面打印测试</p>
<p><span class="Noprint">测试1:
<input type=button value=打印 onclick="window.print()">
<INPUT type=button value=打印 onclick="document.execCommand('Print')">
</span>
</p>
<p class="Noprint">测试2:
<input class="Noprint" type=button value=打印 onclick="dayin()">
<input class="Noprint" type=button value=直接打印 onclick="dayin1()">
<input class="Noprint" type=button value=页面设置 onclick="pageSetup()">
<input class="Noprint" type=button value=打印预览 onclick="preView()">
</p>
<style media=print>
.Noprint{display:none;}
</style>
<script language="JavaScript">
function dayin(){window.print()}
function dayin1(){try{document.all.WebBrowser.ExecWB(6,6)}catch(e){alert("您的浏览器不支持此功能,需要5.5以上版本")}}
function pageSetup(){try{document.all.WebBrowser.ExecWB(8,1)}catch(e){alert("您的浏览器不支持此功能,需要5.5以上版本")}}
function preView(){try{document.all.WebBrowser.ExecWB(7,1)}catch(e){alert("您的浏览器不支持此功能,需要5.5以上版本")}}
</script>
<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0></OBJECT>
<p>页面打印测试</p>
<p><span class="Noprint">测试1:
<input type=button value=打印 onclick="window.print()">
<INPUT type=button value=打印 onclick="document.execCommand('Print')">
</span>
</p>
<p class="Noprint">测试2:
<input class="Noprint" type=button value=打印 onclick="dayin()">
<input class="Noprint" type=button value=直接打印 onclick="dayin1()">
<input class="Noprint" type=button value=页面设置 onclick="pageSetup()">
<input class="Noprint" type=button value=打印预览 onclick="preView()">
</p>
首先在网页中添加:
<OBJECT id="WebBrowser" height="0" width="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"
VIEWASTEXT>
</OBJECT>
然后就可以依次加入功能按钮了:
<input onclick="document.all.WebBrowser.ExecWB(6,1)" type="button" value="打印"> <input onclick="document.all.WebBrowser.ExecWB(6,6)" type="button" value="直接打印">
<input onclick="document.all.WebBrowser.ExecWB(8,1)" type="button" value="页面设置">
<input onclick="document.all.WebBrowser.ExecWB(7,1)" type="button" value="打印预览"> <INPUT type="button" value="关闭窗口" onclick="javascript:window.close()">
将这两块东西放到<center class=noprint></center>就不会打印这些按钮了。当然要定义noprint了:
<style media="print">.Noprint { DISPLAY: none }</style>只要把不想打印的东西的css设置成noprint就可以了。
现在就实现了基本的web打印,需要注意的情况如下:
必须将ie的internet选项的安全设置中对于没有标记为安全的ActiveX控件进行...设置成提示或者启用,否则会报错,导致不可用。
如果在vs.net编辑环境下编辑该页面,它经常自动的给object添加多余的参数,有了这些东西,打印就会出错,所以要记得最后保存的时候删除它们。
为了简便并且达到最好的效果,我们可以在一个页面实现编辑和打印,这时候会需要很多的textbox,我们把它的css设置成.edittext
{
overflow-y:visible;
width: 100%;
border-top: none;
border-right: none;
border-bottom: none;
border-left: none;
}就可以实现在打印的时候不显示边框和multiline的textbox不显示滚动条了。
还有一些小经验就是在设置标格宽度的时候,对于A4纸张,横打用920,竖打用640,效果最好。
用CSS实现表格单元格数据自动换行或不换行
用CSS实现表格单元格数据自动换行或不换行
1、自动换行:
<style type="text/css">
.AutoNewline
{
word-break: break-all;/*必须*/
}
</style>
<table>
<tr>
<td class="AutoNewline">自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行自动换行</td>
</tr>
</table>
2、不换行:
<style type="text/css">
.NoNewline
{
word-break: keep-all;/*必须*/
}
</style>
<table>
<tr>
<td class="NoNewline">不换行不换行不换行不换行不换行不换行不换行不换行不换行不换行</td>
</tr>
</table>
分享到:
相关推荐
易语言自动换行打印支持对齐方式。当打印宽度超过纸张宽度时自动换行。编写收银系统时需要对小票内容进行处理,所以写了这个,感觉还可以,所以分享给大家
project 2013的打印换行补丁,主要解决在打印过程中显示出的多行数据无法打印完全的问题。
图片打印,文本打印,多行文本自动换行打印以及打印预览。
易语言输出文本自动换行。文本文件在输出打印时,会遇到需要换行问题,该例程,能解决。
RBuilder报表打印中文换行出乱码的真正解决方法,在繁体系统下解决了自己编程的痛苦。
易语言编辑框字符自动换行。@易语言代码编写例子。
html中让表格td中的多余字体自动换行的
cad单行文字怎么换行的参考.doc
VB 超长文本换行打印 VB 超长文本换行打印 VB 超长文本换行打印
采用代理方式,实现qtableview的文字自动换行
JTable的自动换行。挺好用的。里面还可以设置字体大小。分享一下。
css自动换行css自动换行css自动换行css自动换行css自动换行css自动换行css自动换行css自动换行css自动换行
在工作中评论内容测试遇到评论着的评论内容为:“dddddddddddddddddddddddddddddddddddddddddddddddddd”,错误的评论,在显示评论列表的时候因为有固定宽,但是显示的内容超出的了div的宽,在这种情况下我们需要...
Java读取资源文件时内容过长与换行的处理
主要介绍了Jlabel实现内容自动换行简单实例,具有一定借鉴价值,需要的朋友可以参考下
实现文本框自动换行,像微信的输入框一样,文字多了以后会自动换行
利用NOPI到处Excel时,Cell内容自动换行;
gridview一般换行,强制换行 gridview一般换行,强制换行 gridview一般换行,强制换行
数据库表字段换行方法,表字段中换行的实现找了很久
DataGridView打印机-颜色换行