Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/256.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# 使用c以编程方式更改打印HTML文件的打印机设置(打印机托盘)#_C#_Printing - Fatal编程技术网

C# 使用c以编程方式更改打印HTML文件的打印机设置(打印机托盘)#

C# 使用c以编程方式更改打印HTML文件的打印机设置(打印机托盘)#,c#,printing,C#,Printing,我是c#的新手,我正在做一个打印应用程序,目前我正在使用WebBrowser打印HTML文件,我可以通过编程更改打印机设置而不是通过打印对话框手动更改它吗。我想选择打印机托盘打印不同的HTML文件,希望有人能为我提供解决方案。谢谢 使用printersettings对象 var printerSettings = new System.Drawing.Printing.PrinterSettings(); 然后看看可以使用哪些属性和函数。一种常用的方法是在使用打印机之前更改默认打印机,但就我个

我是c#的新手,我正在做一个打印应用程序,目前我正在使用WebBrowser打印HTML文件,我可以通过编程更改打印机设置而不是通过打印对话框手动更改它吗。我想选择打印机托盘打印不同的HTML文件,希望有人能为我提供解决方案。谢谢

使用printersettings对象

var printerSettings = new System.Drawing.Printing.PrinterSettings();

然后看看可以使用哪些属性和函数。

一种常用的方法是在使用打印机之前更改默认打印机,但就我个人而言,这方面的问题太多了。(例如,打印机在之后没有正确更换,或者用户打印任务同时启动)

你可以用它做更多的事情。然而,它们也有很多工作要做(但在我看来是值得的)。除了设置打印机,还可以设置页眉/页脚/页边距/纸张类型等。 无法在此发布示例项目,但使用基于上面链接中示例的模板,可以使用设置打印机(模板为javascript)

模板是用printertemplate模板编写的,并且{Printer}在编写时被PrinterName替换

然后一些接口开始发挥作用,调用WebBrowser底层的print命令。(via) 伪代码:

    const int print = 6;
    string templatelocation = "FileName";
    ((IOleCommandTarget3)WebBrowser.Document.DomDocument).Exec(IntPtr.Zero, print, 0, ref templatelocation, ref templatelocation);
这是非常有限的信息,它将需要更多的工作仍然让它的工作,但你会有所有的选项,你需要关于html打印。 到目前为止,“简单”的选择。要设置托盘,必须将devmode对象传递给printtemplate。我可以举出一个范例项目,但不知道我今天是否能抽出时间来做

    const int print = 6;
    string templatelocation = "FileName";
    ((IOleCommandTarget3)WebBrowser.Document.DomDocument).Exec(IntPtr.Zero, print, 0, ref templatelocation, ref templatelocation);