How to print directly, without Print Dialog in WPF?

让人想犯罪 __ 提交于 2019-11-29 07:16:06

问题


I just want to know how I can print a flow document without showing Print Dialog in WPF.

Thanks for help…


回答1:


You can use the PrintDialog class without showing the dialog (without calling ShowModal)




回答2:


This is one of the ways you can change default printer or change other settings:

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);



回答3:


Try

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


来源:https://stackoverflow.com/questions/2995559/how-to-print-directly-without-print-dialog-in-wpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!