【问题标题】:Printing a Text file programmatically以编程方式打印文本文件
【发布时间】:2014-07-31 09:26:06
【问题描述】:

我正在尝试制作一个将文本框文本保存到文本文件并打印文本文件的程序。

我找到了这段代码:

System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(@"TempDocument.txt");
psi.Verb = "PRINT";
Process.Start(psi);

Here

但它不会打开一个对话框,它只是在打印。

我想要一个对话框来选择另一台打印机或在 OneNote 中打开。

【问题讨论】:

标签: c# printing process diagnostics


【解决方案1】:

要显示 printDialog,您可以尝试: 但是,我不知道您说的是哪种项目,所以可能不适合。

printDialog = new PrintDialog();
            //when you click on OK
            if (printDialog.ShowDialog() == DialogResult.OK)
            {
            //path is your documents to print location 
            ProcessStartInfo info = new ProcessStartInfo(path);
            info.Arguments = "\"" + printDialog.PrinterSettings.PrinterName + "\"";
            info.CreateNoWindow = true;
            info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            info.UseShellExecute = true;
            info.Verb = "PrintTo";
            System.Diagnostics.Process.Start(info);
            }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-22
    • 2016-10-18
    • 1970-01-01
    • 2017-12-31
    • 1970-01-01
    相关资源
    最近更新 更多