如何在WPF中没有打印对话框的情况下直接打印?
答
您可以使用PrintDialog类类,而不显示对话框(不调用的ShowModal)
答
尝试
PrintDialog dialog = new PrintDialog();
dialog.PrintVisual(_PrintCanvas, "My Canvas");
答
这是可以改变的途径之一默认打印机或更改其他设置:
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);
不幸的是,如果您尝试打印文件有一个dia日志,任何人都知道打印文件的解决方案? – Beno 2012-08-28 04:12:47