C# 打印文件路径将其打印机和纸盘设置为参数
我尝试打印文件,例如C:/exmaple.docx,但我需要为其指定从“打印”对话框中获取的打印机和托盘。我现在不知道如何将纸盘纸张源设置为参数。将打印机设置为参数有效。这是我的代码:C# 打印文件路径将其打印机和纸盘设置为参数,c#,winforms,C#,Winforms,我尝试打印文件,例如C:/exmaple.docx,但我需要为其指定从“打印”对话框中获取的打印机和托盘。我现在不知道如何将纸盘纸张源设置为参数。将打印机设置为参数有效。这是我的代码: System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(); info.Arguments = "\"" + somePrinterName + "\""
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
info.Arguments = "\"" + somePrinterName + "\"";
info.Verb = "C:\\example.docx";
info.FileName = "C:\\example.docx";
info.UseShellExecute = true;
info.CreateNoWindow = true;
info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo = info;
p.Start();
我认为System.Diagnostics命名空间中没有打印机托盘选项,但对于Word文档,可以使用Word Interop库Microsoft.Office.Interop.Word从特定托盘打印 那会让你做一些类似的事情
wordDocument.PageSetup.FirstPageTray = Word.WdPaperTray.wdPrinterUpperBin;
wordDocument.PageSetup.OtherPagesTray = Word.WdPaperTray.wdPrinterLowerBin;
还有一个更充实的例子,开发者可以选择纸盘,但却难以进行双面打印
另见: