我有一个带有条形码图像的ASP面板(右侧)和左侧的项目信息。
当我用Google搜索时,我知道因为无法从服务器端完成,因此我选择在客户端执行,如下面的代码所示。但它让用户选择我不想要的打印机(因为有很多打印机连接到系统)。是否有任何其他方法可以通过默认打印机来实现它。
Javascript方法 -
<script type = "text/javascript">
function PrintPanel() {
var panel = document.getElementById("<%=pnlContents.ClientID %>");
var printWindow = window.open('', '', 'height=400,width=800');
printWindow.document.write('<html><head><title>DIV Contents</title>');
printWindow.document.write('</head><body >');
printWindow.document.write(panel.innerHTML);
printWindow.document.write('</body></html>');
printWindow.document.close();
setTimeout(function () {
printWindow.print();
}, 500);
return false;
}
</script>
服务器端方法 -
void pd_PrintPage(object sender, PrintPageEventArgs e)
{
Graphics g = e.Graphics;
using Font printFont=new Font("Arial",10.0f))
{
g.DrawImage(???)// How to convert my asp panel to image here?
}
}
或者还有其他更好的方法吗?