Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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


JavaScript
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.
Posted
Updated 25-Sep-12 18:25pm
v2
Comments
Unareshraju 25-Sep-12 9:35am    
right now we have not such kind of requirement, if u want u can put half of page to print.
niravbhavsar 25-Sep-12 9:38am    
how?
Ashraff Ali Wahab 25-Sep-12 9:46am    
What you mean by page will not be wasted.If you have 10 lines to print,it will print only 10 lines in the page and remaining page will be blank.are you seeing any other behavior or you want your paper to be magically cut by the printer once printing the 10 lines.

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900