Printing a dynamically created pdf file from ASP.NET on a client machine

I have an application developed in ASP.NET with code behind of C#
On a page I have a grid view, with a Print button. When the user clicks Print, based on certain variables a pdf document is created on the server.
I need to print this file to the client machine after the print button is clicked
I don't mind opening the print dialog on the client to select a printer to print the content,  but I do not want to open Adobe reader.

the pdf file created always has a name with the session id appended, example gkhljwtyhjkl.pdf, so everytime a user logs on it creates a file based on his/her session id, if they click the print button.

Please note two things need to happen within the print click event
1) Creation of a pdf file ---(which I have taken care of)
2) Invoking the printing fnctionality.

Who is Participating?
WMIFConnect With a Mentor Commented:
Need to automatically print a PDF document from your .NET application without annoying dialogs or other user intervention?
Mass Dot NetCommented:
Admins --

This should question probably be moved to [Web Development > Web Languages > ASP.NET]

-= DeathToSpam =-
countrymeisterAuthor Commented:
You are right, can you please move this question to the ASP.NET topic. i don't know how to do that OR do I have to post another question?
Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

did you check out the link that i provided?
countrymeisterAuthor Commented:

I believe the links provided will print on the server machine, not on the client.
Correct me if I am wrong
it will, but that will be the only way to get it printed without bringing up adobe reader on the client.  the server brings it up and chooses the printer to send it to.
countrymeisterAuthor Commented:
okay, before i give it a try, can you tell me what the following code has to do with Acrobar reader
do i have to do something like this for Acrobat
 ProcessStartInfo starter = new ProcessStartInfo(acrord32.exe, arguments)

What are the arguments?

 private static void RunExecutable(string executable, string arguments)
   ProcessStartInfo starter = new ProcessStartInfo(executable, arguments);
   starter.CreateNoWindow = true;
   starter.RedirectStandardOutput = true;
   starter.UseShellExecute = false;
   Process process = new Process();
   process.StartInfo = starter;
   StringBuilder buffer = new StringBuilder();
   using (StreamReader reader = process.StandardOutput)
    string line = reader.ReadLine();
    while (line != null)
     line = reader.ReadLine();
   if (process.ExitCode != 0)
    throw new Exception(string.Format(@"""{0}"" exited with ExitCode {1}. Output: {2}",
executable, process.ExitCode, buffer.ToString());  
just below that code it shows you the arguements.  it is the arguements for printing without showing any prompts.

string pathToExecutable = "c:\...\acrord32.exe";
RunExecutable(pathToExecutable, @"/t ""mytest.pdf"" ""My Windows PrinterName""");
countrymeisterAuthor Commented:
Okay. so pathToExecutable is the location of the Adobe reader on the server
RunExecutable(pathToExecutable, @"/t ""mytest.pdf"" ""My Windows PrinterName"""); has the arguments to pass namely,  

the adobe reader exe location and the pdf file to print and the location of the printer.

So in this case I need to know the clients printer location and name.
This website is accessed by atleast 100 users, so how do I print to each clients printer.
I don't know if there is anyway to know the clients default printer and replace "My Windows PrinterName" with the clients default printer dynamically.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.