I have a PDF file and I want it to print on click of a button. Below is the code for the same -
private void SendToPrinter(string filename)
{
using (PrintDialog Dialog = new PrintDialog())
{
Dialog.ShowDialog();
ProcessStartInfo printProcessInfo = new ProcessStartInfo()
{
Verb = "print",
CreateNoWindow = true,
FileName = filename,
WindowStyle = ProcessWindowStyle.Hidden
};
Process printProcess = new Process();
printProcess.StartInfo = printProcessInfo;
printProcess.StartInfo.Arguments = Dialog.PrinterSettings.PrinterName;
printProcess.Start();
printProcess.WaitForInputIdle();
Thread.Sleep(3000);
if (false == printProcess.CloseMainWindow())
{
printProcess.Kill();
}
}
}
The above code opens the popup for PrintDialog but whatever printer I select, it uses the default printer.
Any ideas?