使用html和javascript打印 [英] print using html and javascript

查看:77
本文介绍了使用html和javascript打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打印HTML和Java脚本文档.但是当我打印页面时,它给我浪费了页面,这是我的内容是10到15行,但是当我使用window.document.print打印时,整个页面都从打印机中出来了.页面切开后留了很多空间,浪费了我一半以上的页面.
我的内容结束后如何 自动剪切 我的页面,这样我的页面就不会被浪费.
我正在使用Epson TM u220卷筒打印机.
我正在使用以下代码


i want to print HTML and java script doc. but when i print the page it give me waste page that is my content is 10 to 15 line but whole page comes out of the printer as i m printing using window.document.print. the page cut after leave a lot of space and my more a\than half page is wasted .
how can i auto cut my page when my content gets over so my page will not be wasted.
i m using Epson TM u220 roll printer.
i am using following code


var display_setting="toolbar=yes,location=no,directories=yes,menubar=yes,";
                display_setting+="scrollbars=yes,width=300,height=400, left=100, top=25";
                var content_innerhtml = document.getElementById("displaybill").innerHTML;
                var document_print=window.open("","",display_setting);
                //document_print.document.open();
                var str='<html><body><div style="overflow:auto; width:210px;"> <center style="font-size:18px;">Test bill</center>';
                document_print.document.write(str);

                document_print.document.write('<hr/>');
                document_print.document.write('<div style="width:210px;font-size:18px;">Date : &nbsp;'+myvariable+'</div>');
                document_print.document.write('<hr/>');
                document_print.document.write('<table style="width:200px;font-size:18px;" ><tr ><td width="50%" ><b>Item Name</b></td> <td width="20%" style="text-align:right;font-size:18px;"><b>Qty.</b></td> <td width="30%" style="font-size:18px;text-align:right;"><b>Rs.</b></td></tr>');
                document_print.document.write('<tr><td>my detail </td><td>my detail </td><td>my detail </td></tr>');
                document_print.document.write('<tr><td>my detail </td><td>my detail </td><td>my detail </td></tr>');
                document_print.document.write('<tr><td>my detail </td><td>my detail </td><td>my detail </td></tr>');
                document_print.document.write('<tr><td>my detail </td><td>my detail </td><td>my detail </td></tr>');
                document_print.document.write('</table>');
                document_print.document.write('<hr/>');

                document_print.print();
                document_print.close();



我希望在打印完上述几行后自动剪切而不会使页面空白.



i want the auto cut after above lines are printed without leaving page blank.

推荐答案

通常,要解决HTML的打印问题,您最好提供一个打印选项. br/>
当用户要求打印时,您将创建另一个窗口,其中包含需要打印的数据.在该页面上,用户可以使用常规打印命令进行打印
In general to solve a printing issue with HTML you better give an option for printing.

When user would request for printing you make another window with required data to print. from that page user can print using normal print command


这篇关于使用html和javascript打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆