【发布时间】:2013-08-19 18:36:20
【问题描述】:
以下代码至少可以在 Windows 7 中完美打印 pdf 文件,但在 Windows 8 中会报错:
Process process = new Process();
//process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.FileName = defFile;
if (rwPrinter.Length > 0)
{
process.StartInfo.Verb = "printto";
process.StartInfo.Arguments = "\"" + rwPrinter + "\"";
}
else
{
process.StartInfo.Verb = "print";
}
process.Start();
这里是错误的一些细节:
************** Exception Text **************
System.ComponentModel.Win32Exception (0x80004005):
No application is associated with the specified file for this operation
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at ECitation.Form1.process_ticket(String jobdo)
at ECitation.Form1.btnPrint_Click(Object sender, EventArgs e)
我知道无论如何都有一个用于 pdf 文件的 adobe 阅读器,但我不知道在 Windows 8 上工作需要什么,所以这个错误不会再次发生。
编辑,现在这在 Windows 8 中很奇怪: printto 未被识别为内部或外部命令
我尝试用谷歌搜索这个,但很震惊没有出现任何结果。 我要做的就是以编程方式将我的文档打印到特定的打印机。
【问题讨论】: