Click here to Skip to main content
15,914,419 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I want to print a pdf file without opening Adob reader.
Below is the code which I am using.
/////////////////////////////////////////////////////////////
C#
Process p = new Process();
PrintDialog printDlg = new PrintDialog();
p.EnableRaisingEvents = true;
p.StartInfo = new ProcessStartInfo()
{
    CreateNoWindow = true,
    Verb = "print",
    FileName = "C:\Users\vivek.thazhepurayil\Desktop\Test.pdf",
    Arguments = "/d:" + printDlg.PrinterSettings.PrinterName,
    WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
};
try
{
    p.Start();
}
catch
{
}

//////////////////////////////////////////////

But after printing it, the Adobe Reader is poped up. How to prevent this dobe Reader pop?
Posted
Updated 8-Aug-12 1:25am
v2
Comments
Kenneth Haugland 8-Aug-12 7:27am    
Add a finally block and kill adobe... ? :)
Sergey Alexandrovich Kryukov 8-Aug-12 18:55pm    
...After another change of my lab computer, second in a row, I finally did somewhat better tune-up (including removing the pre-installed stuff) and -- finally! -- got rid of one of the most annoying products I hated from the very beginning -- Adobe Acrobat reader. What a relief! I found that there are no cases when it could be useful. Honestly, kill Adobe.
--SA
Kenneth Haugland 8-Aug-12 18:58pm    
LOL... Not quite what I meant, but :)
Sergey Alexandrovich Kryukov 8-Aug-12 19:49pm    
I understand that. I generalize: kill it, bit kill it more.
--SA
Kenneth Haugland 8-Aug-12 19:55pm    
Hmm... I just though of something. You can start Excel with visible = false, perhaps you could do that with Adobe also. Using Excel interop its a pain if you open 100 files , and youll see each on the screen as it gets opened in the same application.... Shoulkd be a printer setting that allows you to not open adobe when printing to is... or?

1 solution

Check this link to kill adobe application, Check the last post written by Binayaraj

http://social.msdn.microsoft.com/Forums/eu/csharpgeneral/thread/56bfe546-680a-45bb-b904-3c9570a6e6a7[^]

also check this to kill an application.

http://www.dreamincode.net/code/snippet1543.htm[^]
 
Share this answer
 
Comments
vivektp 8-Aug-12 9:13am    
This solution will close adobe reader if user manually opened an adobe reader.Is there any other solution ?
Santhosh Kumar Jayaraman 8-Aug-12 9:19am    
have u checked the first link???
http://social.msdn.microsoft.com/Forums/eu/csharpgeneral/thread/56bfe546-680a-45bb-b904-3c9570a6e6a7

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