Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print directly, without Print Dialog in WPF?

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

Thanks for help…

like image 434
Raj Avatar asked Jun 08 '10 07:06

Raj


2 Answers

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

like image 159
Nir Avatar answered Sep 23 '22 03:09

Nir


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);
like image 45
el_shayan Avatar answered Sep 25 '22 03:09

el_shayan