winform程序在windows2008系统无法打印是怎么回事儿

.Net技术 码拜 8年前 (2016-05-17) 901次浏览
程序在windows2003和XP系统可以打印,
winform程序在windows2008系统无法打印是怎么回事儿
但是新配置了一台2008系统服务器,点击打印按钮没反应
打印代码如下:
public void Print()
{
PrintDialog pp = new PrintDialog();
PrintDocument pd = new PrintDocument();
pp.AllowSomePages = true;
pp.ShowHelp = true;
pp.Document = pd;
DialogResult result = pp.ShowDialog();
if (result == DialogResult.OK)
{
//打印小票设置边距
Margins margin = new Margins(20, 20, 10, 20);
pd.DefaultPageSettings.Margins = margin;
pd.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
try
{
pd.Print();//连接打印机端口
ClientInfo.state = 0;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, “打印出错”, MessageBoxButtons.OK, MessageBoxIcon.Error);
pd.PrintController.OnEndPrint(pd, new PrintEventArgs());
}
}
}
/// <summary>
/// 将收费结果填充到图片模版
/// </summary>
///
private void GetResultIntoImage(ref Image temp, string p, string ClientID, string ClientName,string ClientAddress)
{
//读取模版
Graphics _graphics = Graphics.FromImage(temp);
Font _font = new Font(“宋体”, 12);
Brush _brush = new SolidBrush(Color.Black);
//填充数据到图片模版(位置要在制作图片模版的时候度量好)
_graphics.DrawImage(temp, 0, 0, temp.Width, temp.Height);
_graphics.DrawString(ClientID, _font, _brush, 50, 20);
_graphics.DrawString(ClientName, _font, _brush, 200, 20);
_graphics.DrawString(ClientAddress, _font, _brush, 400, 20);
_graphics.Dispose();
}
这是什么问题呢?
解决方案

40

在win2008上安装vs,调试程序看问题在哪里

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明winform程序在windows2008系统无法打印是怎么回事儿
喜欢 (0)
[1034331897@qq.com]
分享 (0)