javascript - distorted Print page after click on print button -


after clicking on print button , on printview can see page style bad formed . can see demo :

http://rogatech.somee.com/print.aspx?darkhastid=13921230

how can solve problem? test other codes form internet no 1 couldn't me...

asp.net codes:

<input type="button" onclick="javascript:printpartofpage('div1')" value="print" /> <div align="right" id="div1" style=" width:21cm; height:29.7cm; margin-top:20px; direction:rtl "> <div style="border-color: black; border-width:1px; border-style:solid; width:595; height:130px"><img src="roga arm.png" alt=""  style=" width:110px; height:110px; margin-top:5px; margin-right:5px; margin-bottom:5px;" /> <span align="left" style=" float:left ;text-align:right;margin-left: 70px; margin-top:5px">شماره درخواست :  <asp:label id="darkhastidlabel" runat="server"                              text='<%# eval("darkhastid") %>' /></span>                <div align="left" style="margin-top:-80px;margin-bottom:7px;margin-left: 110px; ">پیوست : </div>     <br />   <div style=" float:left;margin-left: 116px; margin-top:-5px ; margin-bottom:15px; " align="left">تاریخ : </div>                <div align="center"  style=" font-family:'bkoodakbold'; font-size:22px; color:black; font-weight:bold;  margin-top:-40px; vertical-align:middle;"> گروه مهندسی و تحقیقاتی روگاتکنیک</div> </div> <br /> <div style="border-color: black; border-width:1px; border-style:solid; width:595"> <div style=" margin: 5px 20px 100px 5px;">  //listview code  </div>         </div>     </div> 

javascript:

<script type="text/javascript"> <!--     function printpartofpage(elementid) {         var printcontent = document.getelementbyid(elementid);         var windowurl = 'about:blank';         var uniquename = new date();         var windowname = 'print' + uniquename.gettime();         var printwindow = window.open(windowurl, windowname, 'left=50000,top=50000,width=0,height=0');          printwindow.document.write(printcontent.innerhtml);         printwindow.document.close();         printwindow.focus();         printwindow.print();         printwindow.close();     } // --> </script> 

your stylesheets have attribute media="screen" specified. there no styles that'll apply print media @ all.

you should either remove attribute or specify separate css file attribute media set "print" apply print media.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -