我需要创建发票查询并以A6格式打印所有这些(这就是为什么我在一个javascript中给了style ='height:128mm;'到div。而且我尝试改变那个样式设置仍然没有进展)打印对话框。我是从后面的代码创建的
for (int i = 0; i < count; i++)
{
// Create invoice query
Literal lt = new Literal();
lt.Text = "<div style='height:128mm;'><hr><table> ";
lt.Text += "<tbody><tr style='font-size:small;'><td><b>İşlem Tarihi</b></td><td>:</td><td>" + "01.07.2015" + "</td></tr>"
lt.Text += "<tr style='font-size:small;'><td><b>Fatura Türü</b></td><td>:</td><td>" + "TELEKOM" + "</td></tr>";
lt.Text += "<tr style='font-size:small;'><td><b>Kurum</b></td><td>:</td><td>" + "TURKCELL" + "</td>"
lt.Text += "<tr style='font-size:small;'><td><b>Fatura No</b></td><td>:</td><td>" + "5069376085" + "</td></tr>";
lt.Text += "<tr style='font-size:small;'><td><b>Banka Referans No</b></td><td>:</td><td>" + "ASDADSASD^12" + "</td></tr>";
lt.Text += "<tr style='font-size:small;'><td><b>Tesisat No</b></td><td>:</td><td>" + "5069376085" + "</td></tr>";
lt.Text += "<tr style='font-size:small;'><td><b>Müşteri Adı</b></td><td>:</td><td>" + "Egemen uluçay" + "</td></tr>";
lt.Text += "<tr style='font-size:small;'><td><b>Son Ödeme Tarihi</b></td><td>:</td><td>" + "10.07.2015" + "</td></tr>";
lt.Text += "<tr style='font-size:small;'><td><b>Tutar</b></td><td>:</td><td>" + "50 TL" + " TL</td></tr>";
lt.Text += "<tr style='font-size:small;'><td><b>Hizmet Bedeli</b></td><td>:</td><td>" + "1 TL" + " TL</td></tr>";
lt.Text += "<tr style='font-size:small;'><td><b>Toplam Tutar</b></td><td>:</td><td>" + "51 TL" + " TL</td></tr></tbody></table>";
lt.Text += "<br><br><div style='text-align:center;'><span style='text-align:center; font-size:12px;'>" + "Vezne" + "</span>";
lt.Text += "<br><span style='text-align:center; font-size:12px;'>" + "3122319793" + "</span>";
lt.Text += "<br><span style='text-align:center; font-size:12px;'>V.D: " + "Mithatpaşa" + " - " + "11111111111" + "</span>";
lt.Text += "<br><span style='text-align:center; font-size:12px;'>" + "Ankara" + "</span>";
lt.Text += "</div></div>";
Panel3.Controls.Add(lt);
}
这是我在div中的html panel3
<div id="dvPrintReceipts" hidden="hidden">
<asp:Panel runat="server" ID="Panel3"></asp:Panel>
</div>
我的javascript代码;
function PrintPanel() {
var panel = document.getElementById("dvPrintReceipts");
var printWindow = window.open('', '', 'height=400,width=800');
printWindow.document.write('<html><head><title>Kasa Raporu</title>');
printWindow.document.write('<link rel="stylesheet" href="assets/css/bootstrap.min.css" /></head><body >');
printWindow.document.write(panel.innerHTML);
printWindow.document.write('</body></html>');
printWindow.document.close();
setTimeout(function () {
printWindow.print();
}, 500);
return false;
};
在这种情况下,我们的“计数”为2,但是javascript对话框提供了3页,只有第一页格式正确。您可以看到第二张发票的放置错误,第三页出现不必要的情况。
这是printWindow呈现的HTML;
<html>
<head><title>Kasa Raporu</title>
<link rel="stylesheet" href="assets/css/bootstrap.min.css" />
</head>
<body>
<div id="bodyContent_Panel3">
<div style="height: 128mm;">
<hr>
<table>
<tbody>
<tr style="font-size: small;">
<td><b>İşlem Tarihi</b></td>
<td>:</td>
<td>01.07.2015</td>
</tr>
<tr style="font-size: small;">
<td><b>Fatura Türü</b></td>
<td>:</td>
<td>TELEKOM</td>
</tr>
<tr style="font-size: small;">
<td><b>Kurum</b></td>
<td>:</td>
<td>TURKCELL</td>
</tr>
<tr style="font-size: small;">
<td><b>Fatura No</b></td>
<td>:</td>
<td>5069376085</td>
</tr>
<tr style="font-size: small;">
<td><b>Banka Referans No</b></td>
<td>:</td>
<td>ASDADSASD^12</td>
</tr>
<tr style="font-size: small;">
<td><b>Tesisat No</b></td>
<td>:</td>
<td>5069376085</td>
</tr>
<tr style="font-size: small;">
<td><b>Müşteri Adı</b></td>
<td>:</td>
<td>Egemen uluçay</td>
</tr>
<tr style="font-size: small;">
<td><b>Son Ödeme Tarihi</b></td>
<td>:</td>
<td>10.07.2015</td>
</tr>
<tr style="font-size: small;">
<td><b>Tutar</b></td>
<td>:</td>
<td>50 TL TL</td>
</tr>
<tr style="font-size: small;">
<td><b>Hizmet Bedeli</b></td>
<td>:</td>
<td>1 TL TL</td>
</tr>
<tr style="font-size: small;">
<td><b>Toplam Tutar</b></td>
<td>:</td>
<td>51 TL TL</td>
</tr>
</tbody>
</table>
<br>
<br>
<div style="text-align: center;"><span style="text-align: center; font-size: 12px;">Vezne</span><br>
<span style="text-align: center; font-size: 12px;">3122319793</span><br>
<span style="text-align: center; font-size: 12px;">V.D: Mithatpaşa - 11111111111</span><br>
<span style="text-align: center; font-size: 12px;">Ankara</span></div>
</div>
<div style="height: 128mm;">
<hr>
<table>
<tbody>
<tr style="font-size: small;">
<td><b>İşlem Tarihi</b></td>
<td>:</td>
<td>01.07.2015</td>
</tr>
<tr style="font-size: small;">
<td><b>Fatura Türü</b></td>
<td>:</td>
<td>TELEKOM</td>
</tr>
<tr style="font-size: small;">
<td><b>Kurum</b></td>
<td>:</td>
<td>TURKCELL</td>
</tr>
<tr style="font-size: small;">
<td><b>Fatura No</b></td>
<td>:</td>
<td>5069376085</td>
</tr>
<tr style="font-size: small;">
<td><b>Banka Referans No</b></td>
<td>:</td>
<td>ASDADSASD^12</td>
</tr>
<tr style="font-size: small;">
<td><b>Tesisat No</b></td>
<td>:</td>
<td>5069376085</td>
</tr>
<tr style="font-size: small;">
<td><b>Müşteri Adı</b></td>
<td>:</td>
<td>Egemen uluçay</td>
</tr>
<tr style="font-size: small;">
<td><b>Son Ödeme Tarihi</b></td>
<td>:</td>
<td>10.07.2015</td>
</tr>
<tr style="font-size: small;">
<td><b>Tutar</b></td>
<td>:</td>
<td>50 TL TL</td>
</tr>
<tr style="font-size: small;">
<td><b>Hizmet Bedeli</b></td>
<td>:</td>
<td>1 TL TL</td>
</tr>
<tr style="font-size: small;">
<td><b>Toplam Tutar</b></td>
<td>:</td>
<td>51 TL TL</td>
</tr>
</tbody>
</table>
<br>
<br>
<div style="text-align: center;"><span style="text-align: center; font-size: 12px;">Vezne</span><br>
<span style="text-align: center; font-size: 12px;">3122319793</span><br>
<span style="text-align: center; font-size: 12px;">V.D: Mithatpaşa - 11111111111</span><br>
<span style="text-align: center; font-size: 12px;">Ankara</span></div>
</div>
</div>
</body>
</html>
顺便说一下它的asp.net web表单项目。我该怎么做才能解决这个问题?谢谢
答案 0 :(得分:1)
您可以使用page-break-after css规则,因此对于除上一个
之外的所有页面<div style="page-break-after: always;">
<hr>
<table>
<tbody>
<tr style="font-size: small;">
<td><b>İşlem Tarihi</b></td>
<td>:</td>
<td>01.07.2015</td>
</tr>
...
</tbody>
</table>
<br>
<br>
<div style="text-align: center;">
<span style="text-align: center; font-size: 12px;">Vezne</span>
<br>
<span style="text-align: center; font-size: 12px;">3122319793</span>
<br>
<span style="text-align: center; font-size: 12px;">V.D: Mithatpaşa - 11111111111</span>
<br>
<span style="text-align: center; font-size: 12px;">Ankara</span>
</div>
</div>
并在最后一页简单div
没有样式
<div>
<hr>
<table>
...
</table>
<br>
<br>
<div style="text-align: center;">
...
</div>
</div>