execCommand("Print",false,IDon'tUnderstandThisArgument) [英] execCommand("Print", false, IDon'tUnderstandThisArgument)
问题描述
我想做的是让它以横向模式打印而不显示对话框.这是我到目前为止的内容:
What I'm trying to do is get this to print in landscape mode without showing the dialog box. This is what I have so far:
((mshtml.IHTMLDocument2)Browser.Document.DomDocument).execCommand("Print", true, 0);
我知道以横向模式打印的指令需要通过第三个参数发送,但是我不知道如何构造第三个参数来执行此操作.谁能为我提供一些帮助,以使最后一个论点实现我的目标?
I know that the instruction to print in landscape mode needs to be sent through the third argument, but I don't know how to construct the third argument to do this. Can anyone give me some help on how to make this last argument accomplish my goal?
推荐答案
ADDITIONS: This is from Microsoft http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.defaultpagesettings%28v=vs.71%29.aspx
public void Printing()
{
try
{
streamToPrint = new StreamReader (filePath);
try
{
printFont = new Font("Arial", 10);
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.PrinterSettings.PrinterName = printer;
// Set the page orientation to landscape.
pd.DefaultPageSettings.Landscape = true;
pd.Print();
}
finally
{
streamToPrint.Close() ;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
因此,您可能只需将上面示例中的 pd
替换为文档即可.
So you would probably just replace pd
in the example above with your document.
原始答案: 可能集成:
ORIGINAL ANSWER: Possibly integrate:
DefaultPageSettings.Landscape = true;
所以也许是这样的:
((mshtml.IHTMLDocument2)Browser.Document.DomDocument).DefaultPageSettings.Landscape = true;
((mshtml.IHTMLDocument2)Browser.Document.DomDocument).execCommand("Print", true, 0);
由于C#是一个薄弱环节,因此在黑暗中有点刺痛,但是我相信这是我曾经在C#应用程序中做到的方式.
Taking a little bit of a stab in the dark since C# is a weak spot but I believe this is how I once did it from an C# application.
这篇关于execCommand("Print",false,IDon'tUnderstandThisArgument)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!