I am trying to print .pdf and .tif files using C# in windows application.
Printing is done successfully, but my problem is Adobe reader is opening in background for pdf files and windows print dialogue opens for tif files.
Actually i will run my method using a service, so these process should occur silently. What can I do to avoid this?
Here is my code
public void PrintDocument(string filepath)
{
//PrintDialog pd = new PrintDialog();
printProcess.StartInfo.FileName = filepath;
//Also tried usecellexcecution=false;
//Redirect=true; something like this
printProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
printProcess.StartInfo.Verb = "Print";
printProcess.StartInfo.CreateNoWindow = true;
PrinterSettings setting = new PrinterSettings();
setting.DefaultPageSettings.Landscape = true;
printProcess.Start();
printProcess.CloseMainWindow();
}
I have tried to use RawprinterHelper suggested in MSDN, but it prints junk characters.
Get the window handle of the pdf process and then hide it or use process class’s windowstyle to minimize it.
Yes it gets launched because you are using Process.Start.