简体   繁体   English

单击打印按钮后,打印页面变形

[英]distorted Print page after click on print button

after clicking on the print button , on printview you can see that the page style is bad formed . 单击“打印”按钮后,在printview上您可以看到页面样式格式错误。 you can see the demo : 您可以看到演示:

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

how can I solve this problem? 我怎么解决这个问题? I test some other codes form internet but no one couldn't help me... 我测试了互联网上的其他代码,但没人能帮我...

asp.net codes: asp.net代码:

<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: 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 the attribute media="screen" specified. 您的样式表已指定属性media =“ screen”。 So there are no styles that'll apply to print media at all. 因此,根本没有样式可应用于打印介质。

You should either remove that attribute or specify a separate css file with the attribute media set to "print" to apply to print media. 您应该删除该属性或指定属性媒体设置为“ print”的单独的css文件,以应用于打印媒体。

finally and after attempts , I could solve my problem. 最后,经过尝试,我可以解决我的问题。 It hasn't need to any other stylesheet for print. 它不需要任何其他样式表即可打印。 at first I have deleted browser history cached, and then add some style like direction and align to my dives and now all the thing looks okay. 首先,我删除了缓存的浏览器历史记录,然后添加一些样式(如方向)并使其与潜水对齐,现在一切正常。 thanks all for your attention. 谢谢大家的关注。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM