[英]Printing html file from windows application is not working when we set default browser as chrome (other than IE)
I have to print html file when user clicks on print button and it is working fine (prompts print dialog) when I set default browser as IE. 当我将默认浏览器设置为IE时,我必须在用户点击打印按钮时打印html文件并且工作正常(提示打印对话框)。 If I change default browser to chrome or firefox other than IE, the code does not prompting print dialog instead it just opens html file in the browser.
如果我将默认浏览器更改为除IE之外的chrome或firefox,则代码不会提示打印对话框,而只是在浏览器中打开html文件。 Can you please let me know what configuration I have missed in the below code?
你可以告诉我在下面的代码中我错过了什么配置吗?
string TempFile = @"D:\test.html";
ProcessStartInfo Params = new ProcessStartInfo();
Params.FileName = "iexplore.exe";
Params.Arguments = TempFile;
Params.UseShellExecute = false;
Params.Verb = "print";
Params.WindowStyle = ProcessWindowStyle.Hidden;
Params.CreateNoWindow = true;
Process.Start(Params);
Finally I got the solution for this issue. 最后我得到了这个问题的解决方案。 The below code works like a charm!!
以下代码就像一个魅力!
using (Process exeProcess = new Process())
{
string TempFile = @"D:\test.html";
exeProcess.StartInfo.FileName = "rundll32";
exeProcess.StartInfo.Arguments = @"system32\mshtml.dll,PrintHTML """ + TempFile + @"""";
exeProcess.StartInfo.UseShellExecute = true;
exeProcess.Start();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.