0

I am trying to print a PDF in a C# ASP.NET application with the orientation set to landscape mode. This currently works in my dev environment but when I move it to our web server, it does not work. I can see Adobe reader open as a background process but that's it. I've read multiple posts that say to impersonate an account with unlimited access, I did this but not luck.

ProcessStartInfo info = new ProcessStartInfo();
info.Verb = "PrintTo";
info.Arguments = "Test Copier";
info.FileName = "File PAth";
info.CreateNoWindow = false;
info.WindowStyle = ProcessWindowStyle.Hidden;

Process p = new Process();
p.StartInfo = info;
p.Start();
HP1104
  • 93
  • 9
  • For a start, none of the code you have posted is trying to print a PDF, just to open a process. Additionally, when you say `print a PDF`, do you mean display on the screen in a web browser, or print to a printer? Trying to impersonate accounts from an ASP application is difficult and dangerous. If you want to display a PDF in a browser, just link to it and let the client plugin deal with it. Failing that, post more detail in your question as what you're asking is unclear. – Alex Aug 09 '16 at 20:03
  • Another thought, what are you doing launching a process on a web server anyway? I don't know a single network admin who would allow any application which launched processes this way! – Alex Aug 09 '16 at 20:04
  • i want to print to a printer. i have posted code also – HP1104 Aug 09 '16 at 20:04
  • if you have any other code to print pdf file to printer. then please let me know – HP1104 Aug 09 '16 at 20:05
  • 1
    The only reliable way to do it is to get the address of a network or local printer, and send the document to it. Calling a process start with a print verb will try to spawn a process which IIS will not allow. If you really want to go down this route, try this post - http://stackoverflow.com/questions/3729153/printing-from-asp-net-to-a-network-printer – Alex Aug 09 '16 at 20:09
  • Do you know how i can "set Application Pool Identity to Administrator account on IIS" using web config file ? – HP1104 Aug 10 '16 at 13:40
  • If you mean the web config file for the ASP application itself, I don't believe this can be done. Configuring the pool means configuring IIS directly. This guide will show you the process. http://www.iis.net/learn/manage/configuring-security/application-pool-identities – Alex Aug 10 '16 at 13:41
  • Thanks for your reply. i want to set this from web config file if possible or if you have any other option to print document using c#, then please share it with me. All options are working well in local but not on server – HP1104 Aug 10 '16 at 14:16

0 Answers0