Click here to Skip to main content
15,888,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 i have to do to avoid this .i am really in need of help.
Here is my code
C#
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();
        }


Also i try to use RawprinterHelper suggested in MSDN.But it prints junk characters.
Posted

1 solution

you can use the default setting :
C#
doc.PrintController = new StandardPrintController();
doc.Print();

and maybe that link will help you :
http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/8ce3dd94-ff2c-4c3c-ba85-f67b9dd2f2e8[^]
regards..
 
Share this answer
 
Comments
b4usat 18-Aug-11 23:57pm    
Thanks for reply.My problem is not printing.Adobe reader is opening while printing files.Also windows print dialog on printing .tif files.I have to restrict this.I alredy gothrough the given link.
loai_maane 3-Dec-18 10:58am    
did you get any solution for you issue dear ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900