Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# IHTMLDocument2无对话框打印_C#_Printing_Ihtmldocument2 - Fatal编程技术网

C# IHTMLDocument2无对话框打印

C# IHTMLDocument2无对话框打印,c#,printing,ihtmldocument2,C#,Printing,Ihtmldocument2,我一直在做一个自动打印HTML发票的项目。这尤其具有挑战性,因为我需要保留CSS格式 根据建议,我发现自己正在使用IHTMLDocument2进行打印。我应该能够: mshtml.IHTMLDocument2 doc = new mshtml.HTMLDocument() as mshtml.IHTMLDocument2; doc.write(htmlContent); //htmlContent is a string of HTML doc.execCommand("PRINT", fals

我一直在做一个自动打印
HTML
发票的项目。这尤其具有挑战性,因为我需要保留
CSS
格式

根据建议,我发现自己正在使用
IHTMLDocument2
进行打印。我应该能够:

mshtml.IHTMLDocument2 doc = new mshtml.HTMLDocument() as mshtml.IHTMLDocument2;
doc.write(htmlContent); //htmlContent is a string of HTML
doc.execCommand("PRINT", false, null);
第二个参数指定是否生成
打印机选项
框,但没有帮助。我已经读到,使用
打印
总是会出现一个对话框,但是我还没有找到替代方法

有什么想法吗?

根据:

印刷品

打开“打印”对话框,以便用户可以打印当前页面

因此,我认为没有办法绕过这种行为。请尝试为应用程序使用其他类,或在打印过程中打开“打印”对话框。
您应该注意,您必须在
execCommand
方法中提供
true
作为secord参数(
showUI[in,可选]