C#ProcessStartInfo打印副本到打印机

时间:2017-03-09 10:51:58

标签: c# printing

我希望能够从打印机对话框中打印多份副本并将它们发送到打印机。

using (System.Windows.Forms.PrintDialog printerDialog = new System.Windows.Forms.PrintDialog())
{
    string printer;
    if (printerDialog.ShowDialog() == DialogResult.OK)
    {
        printer = printerDialog.PrinterSettings.PrinterName;
        System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(GetDocPath("StickerBlank.docx", Client.ClientID.ToString()));
        for (int i = 0; i < printerDialog.PrinterSettings.Copies; i++)
        {
            Thread.Sleep(3000);
            using (var regWord = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe"))
            {
                //string arguments = String.Format(@"-t ""{0}"" ""{1}""", printerDialo, printer);
                if (regWord == null)
                {
                    info.Arguments = "\"" + printer + "\"";
                    info.CreateNoWindow = true;
                    info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                    info.UseShellExecute = true;
                    info.Verb = "Print";
                }
                else
                {
                    info.Arguments = "\"" + printer + "\"";
                    info.CreateNoWindow = true;
                    info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                    info.UseShellExecute = true;
                    info.Verb = "PrintTo";
                }
            }   
            System.Diagnostics.Process.Start(info);
        }
    }
}

它的工作原理但问题是,作为我的模板的word文档打开的次数与从printdialog设置的副本一样多。有没有办法指定我想要5个副本作为参数?

0 个答案:

没有答案