【问题标题】:How to achieve same print functionality of Silverlight into WPF?如何在 WPF 中实现与 Silverlight 相同的打印功能?
【发布时间】:2020-05-26 04:00:01
【问题描述】:

我们正在将 SilverLight 应用程序迁移到 WPF 中,在我们的打印应用程序中,我们使用了 System.Windows.Printing。相同的命名空间在具有 System.Drawing.Printing 命名空间的 WPF 中不可用,因为此现有功能无法按预期工作。我们需要为此编写新的打印。有什么方法可以在不编写新代码的情况下实现相同的目标。

【问题讨论】:

  • 这是 WPF 的 MSDN Printing Overview。 WPF 打印使用System.Printing 命名空间。 System.Drawing.Printing 用于 WinForms。
  • 谢谢,我已经用过了,但其中没有一些功能。
  • 如果您能具体说明您所指的功能会很有帮助。

标签: wpf silverlight printing


【解决方案1】:

在 WPF 中使用打印机选择打印文件的实现

    private static void PrintFile(string pathToFile)
    {
        PrintDialog pDialog = new PrintDialog();
        bool? print = pDialog.ShowDialog();
        if (print == true)
        {
            string printerName = pDialog.PrintQueue.FullName;
            Process p = new Process
            {
                StartInfo = new ProcessStartInfo()
                {
                    Arguments = "\"" + printerName + "\"",
                    CreateNoWindow = true,
                    Verb = "PrintTo",
                    FileName = pathToFile
                }
            };
            p.Start();
        }
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-10
    • 2017-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多