【发布时间】:2013-12-30 19:08:35
【问题描述】:
我有 3 台打印机连接到我的 PC,在我的 win 表单上,我选择了按名称打印,在代码中(我不使用 PrintDialog)。每台打印机都有不同的纸张尺寸(小、中、大)。有什么方法可以获取当前打印机的纸张尺寸。 我试试
Console.WriteLine(e.PageSettings.Bounds.ToString());
Console.WriteLine(e.PageSettings.PaperSize.ToString());
Console.WriteLine(e.Graphics.VisibleClipBounds.ToString());
Console.WriteLine(e.Graphics.ClipBounds.ToString());
我从我的委托参数方法中得到变量 e:
// When I launch my printer (in class constructor):
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(PrintLabel);
//.... other code
//My delegate method:
private void PrintLabel(object o, PrintPageEventArgs e)
{
//This is my code from above:
Console.WriteLine(e.PageSettings.Bounds.ToString());
// other code
}
但无论我使用哪种打印机,它都会显示相同的尺寸。 提前致谢。
【问题讨论】:
-
您应该包括如何获得变量
e。 -
@ANeves 查看已编辑的问题。