Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
here is the code for printing values of a Div.
JS:"
Quote:
<script language="javascript" type="text/javascript">

function PrintDivContent(strid) {

var prtContent = document.getElementById(strid);

var WinPrint =

window.open('', '', 'letf=0,top=0,toolbar=0,sta­tus=0');

WinPrint.document.write(prtContent.innerHTML);

WinPrint.document.close();

WinPrint.focus();

WinPrint.print();

}

<</script>"
and Div to which values to be printed:
"
Quote:






                                             M.P.
Filaments


          


     Denier  :<asp:TextBox
ID="TextBox1" runat="server" CssClass="style1">
    Gross Weight :<asp:TextBox ID="TextBox6" runat="server"
CssClass="style1" AutoPostBack="true">




      Shade  :<asp:TextBox ID="TextBox2" runat="server"
CssClass="style1">
       Tare Weight :<asp:TextBox
ID="TextBox7" runat="server"
CssClass="style1" AutoPostBack="true"
ontextchanged="TextBox7_TextChanged1">




  Shade No:<asp:TextBox ID="TextBox3" runat="server"
CssClass="style1">
          Net Weight:<asp:TextBox
ID="TextBox8" runat="server"
CssClass="style1" AutoPostBack="true">




     Box
No :
<asp:TextBox ID="TextBox4" runat="server"
CssClass="style1">
     No. Of Cones :<asp:TextBox ID="TextBox9" runat="server"
CssClass="style1">




     Lot
No  :
<asp:TextBox ID="TextBox5" runat="server"
CssClass="style1">
          Packed By:<asp:TextBox ID="TextBox10" runat="server"
CssClass="style1">




"
and button which will print:
"
Quote:
<asp:Button ID="btnPrint" Text="Print" OnClientClick="javascript:PrintDivContent('print');"

runat="Server" Width="94px" Height="30px"
style="font-weight: 700; color: #0099FF; background-color: #CC3300" />
So Now question is that I am using IE to run this (browser), i want to get the things printed in the 6*4 dimensions. now it is taking A4 size and printing the page with the values in A4 dimensions.
so i want the modification in the code so that it should print the page according to the Dimension provided to it.like 6 width and 4 high.
and continue the printing like this without leaving or ejecting empty page.
"
Posted

1 solution

 
Share this answer
 
Comments
Shantanu sinha 7-Feb-14 6:48am    
still my printer is printing full page A4.
i want to print it in 6 inch width and 4 inch height
Ahmed Bensaid 7-Feb-14 8:29am    
In the last comment of my link : http://www.w3.org/TR/css3-page/#page-size

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