Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript HTML
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.
Posted 25-Sep-12 3:30am
Edited 25-Sep-12 18:25pm
v2
Comments
Unareshraju at 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 at 25-Sep-12 9:38am
   
how?
Ashraff Ali Wahab at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 595
1 OriginalGriff 295
2 CPallini 210
3 PIEBALDconsult 150
4 Fredrik Bornander 140
0 OriginalGriff 5,835
1 Sergey Alexandrovich Kryukov 5,263
2 CPallini 4,750
3 George Jonsson 3,227
4 Gihan Liyanage 2,487


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 26 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100