我正在使用ProcessStartInfo
在我的C#项目中打印我的pdf文件。但是我打印的文件在打印时切断了pdf文件的顶部和底部。但是,当我通过右键单击pdf文件打印相同的文件时,它会正确打印。
这是我的代码:
System.Diagnostics.Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = filename; // use default app to execute verb
//assert: can only go to local default printer
startInfo.Verb = "Print"; //prints to default printer
//try to keep Window hidden - work in background
startInfo.UseShellExecute = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.CreateNoWindow = true;
// set process to startInfo and execute start
process.StartInfo = startInfo;
process.Start();
process.WaitForExit(10000);
process.CloseMainWindow();
process.Close();
答案 0 :(得分:1)
这是以毫秒为单位。所以它只会等待10秒钟。那够长了吗?
process.WaitForExit(10000);
考虑
process.WaitForExit();