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,可选]
)