【问题标题】:How to print directly, without Print Dialog in WPF?如何在 WPF 中没有打印对话框直接打印?
【发布时间】:2011-03-01 01:09:19
【问题描述】:

我只想知道如何在 WPF 中不显示打印对话框的情况下打印流文档。

感谢您的帮助……

【问题讨论】:

    标签: c# wpf printing flowdocument


    【解决方案1】:

    这是更改默认打印机或更改其他设置的方法之一:

    using System.Printing;  //add reference to System.Printing Assembly
                            //if you want to modify PrintTicket, also add
                            //reference to ReachFramework.dll (part of .net install)
    ...
    
    var dlg = new PrintDialog();
    
    dlg.PrintQueue = printer; // this will be your printer. any of these: new PrintServer().GetPrintQueues()
    dlg.PrintTicket.CopyCount = 3; // number of copies
    dlg.PrintTicket.PageOrientation = PageOrientation.Landscape;
    
    dlg.PrintVisual(canvas);
    

    【讨论】:

    • 不幸的是,如果您尝试打印到文件有一个对话框,有人知道打印到文件的解决方案吗?
    【解决方案2】:

    试试

    PrintDialog dialog = new PrintDialog();
    dialog.PrintVisual(_PrintCanvas, "My Canvas");
    

    【讨论】:

      【解决方案3】:

      您可以使用 PrintDialog 类而不显示对话框(无需调用 ShowModal)

      【讨论】:

        猜你喜欢
        • 2011-04-05
        • 1970-01-01
        • 1970-01-01
        • 2015-06-30
        • 2015-07-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多