Solved

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

Posted on 2006-11-16
9
616 Views
Last Modified: 2008-12-10
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.

Thanks
0
Comment
Question by:countrymeister
  • 4
  • 4
9 Comments
 
LVL 22

Accepted Solution

by:
WMIF earned 500 total points
ID: 17958281
Need to automatically print a PDF document from your .NET application without annoying dialogs or other user intervention?
http://aspalliance.com/514
0
 
LVL 9

Expert Comment

by:deathtospam
ID: 17958311
Admins --

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


-= DeathToSpam =-
0
 
LVL 1

Author Comment

by:countrymeister
ID: 17958704
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?
0
 
LVL 22

Expert Comment

by:WMIF
ID: 17958723
did you check out the link that i provided?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:countrymeister
ID: 17958767
WMIF

I believe the links provided will print on the server machine, not on the client.
Correct me if I am wrong
0
 
LVL 22

Expert Comment

by:WMIF
ID: 17958780
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.
0
 
LVL 1

Author Comment

by:countrymeister
ID: 17958855
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;
   process.Start();
   StringBuilder buffer = new StringBuilder();
   using (StreamReader reader = process.StandardOutput)
   {
    string line = reader.ReadLine();
    while (line != null)
    {
     buffer.Append(line);
     buffer.Append(Environment.NewLine);
     line = reader.ReadLine();
     Thread.Sleep(100);
    }
   }
   if (process.ExitCode != 0)
   {
    throw new Exception(string.Format(@"""{0}"" exited with ExitCode {1}. Output: {2}",
executable, process.ExitCode, buffer.ToString());  
   }
  }
0
 
LVL 22

Expert Comment

by:WMIF
ID: 17958886
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""");
0
 
LVL 1

Author Comment

by:countrymeister
ID: 17959053
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Autosum input type=text when checkbox is true 28 82
Classic ASP - x-editable save to SQL 3 80
Group by correlation 4 55
Using Classic ASP inside HTML pages 2 56
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now