如何在WPF中没有Print Dialog的情况下直接打印?

时间:2010-06-08 07:51:18

标签: c# wpf printing flowdocument

我只是想知道如何在不在WPF中显示Print Dialog的情况下打印流文档。

感谢您的帮助...

3 个答案:

答案 0 :(得分:16)

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

答案 1 :(得分:15)

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

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 :(得分:3)

尝试

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