如何在C#中手动设置打印机宽度和高度 [英] How to set printer width and height manually in C#

查看:541
本文介绍了如何在C#中手动设置打印机宽度和高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我点击打印按钮时,我的数据打印为纸张大小为5 * 4 

如何设置宽度和高度
i am使用java脚本进行宽度和高度显示对话框
i我写的代码是否正确?

任何人提供此页面的示例调整大小以在打印机中打印
请帮助我


函数PrintPanel(){
var panel = document.getElementById(<% = pnlContents.ClientID %> );
var printWindow = window.open('','','height = 600,width = 800');
printWindow.document.write('< html > < head > ; < title > DIV内容< / title > ');
printWindow.document.write('< / head > < body > ');
printWindow.document.write(panel.innerHTML);
printWindow.document.write('< / body > < / html > ');
printWindow.document.close();


setTimeout(function(){
printWindow.print();
printWindow.resizeTo(500,400);
printWindow.focus();
printwindow.window.close();


},500);


返回false;
}

解决方案

你在这里做的是设置printWindow的大小,它与论文无关您打印的尺寸!

实际上您无法使用JavaScript设置打印机属性。

您可以使用CSS选择器代码> @page格式化页面打印机: https://developer.mozilla.org/en-US/docs/Web/CSS / @ page [ ^

when i click print button my data print in paper size as 5*4

how to set width and height
i am using java script for width and height to display dialog
i am written code is correct?

anyone provide example for this page resize to print in printer
kindly help me


function PrintPanel() {
            var panel = document.getElementById("<%=pnlContents.ClientID %>");
            var printWindow = window.open('', '', 'height=600,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();
                printWindow.resizeTo(500,400);
                printWindow.focus();
                printwindow.window.close();


            }, 500);


            return false;
        }

解决方案

What are you doing here is setting the size of the printWindow, it has nothing to do with the paper size you are printing on!
In fact you can not set printer properties from JavaScript.
what you can do is using CSS selector code>@page to format the page for printer: https://developer.mozilla.org/en-US/docs/Web/CSS/@page[^]


这篇关于如何在C#中手动设置打印机宽度和高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆