簡體   English   中英

單擊打印按鈕后,打印頁面變形

[英]distorted Print page after click on print button

單擊“打印”按鈕后,在printview上您可以看到頁面樣式格式錯誤。 您可以看到演示:

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

我怎么解決這個問題? 我測試了互聯網上的其他代碼,但沒人能幫我...

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:

<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>

您的樣式表已指定屬性media =“ screen”。 因此,根本沒有樣式可應用於打印介質。

您應該刪除該屬性或指定屬性媒體設置為“ print”的單獨的css文件,以應用於打印媒體。

最后,經過嘗試,我可以解決我的問題。 它不需要任何其他樣式表即可打印。 首先,我刪除了緩存的瀏覽器歷史記錄,然后添加一些樣式(如方向)並使其與潛水對齊,現在一切正常。 謝謝大家的關注。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM