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

Raj*_*ahu 13 c# printing wpf flowdocument

我只想知道如何打印流文档而不在WPF中显示Print Dialog.

感谢帮助…

Nir*_*Nir 16

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


el_*_*yan 16

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

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);
Run Code Online (Sandbox Code Playgroud)

  • 不幸的是,如果你尝试打印到文件有一个对话框,任何人都知道打印到文件的解决方案? (4认同)