0

I've been trying to get this working for the past couple of days and tried every solution suggested including the one here:

System.Diagnostics.Process.Start not work from an IIS

This code (ASP.NET MVC Web Application) works perfectly on IIS7 (Windows 7).

The code just print a PDF file using Adobe Reader in a local printer (intranet) from the server:

// print receipt
ProcessStartInfo psInfo = new ProcessStartInfo();
psInfo.FileName = acrobatReaderPath;
psInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(psInfo.FileName);
psInfo.Arguments = String.Format("/s /o /h /t \"{0}\" \"{1}\"", filePath, printerName);
psInfo.WindowStyle = ProcessWindowStyle.Hidden;
psInfo.CreateNoWindow = true;
psInfo.UseShellExecute = true;
Process process = Process.Start(psInfo);

The Application Pool Identity is a local privileged account. Like I said before, it works on IIS7.

The strange thing is that I can see the background process started (AcroRd32.exe) in the Task Manager including the Command Line used to launch it. If I copy the Command Line and run it the PDF prints without problem.

Is there something I'm missing?

I know there are better ways to do this. Suggestions are also welcome.

UPDATE:

Clarification: The issue is that the process is not finishing and the PDF is not printing.

Apparently the issue is more of a bitness (32 vs 64). I'm still debugging.

The code IS PRINTING the PDFs in the following scenarios:

  • Visual Studio 2012 IIS Express on Windows 7 (64 bits)
  • IIS7 on Windows Server 2008 Standard (32 bits)

The code IS NOT PRINTING the PDFs in the following scenarios:

  • Visual Studio 2012 IIS7 on Windows 7 (64 bits)
  • IIS8 on Windows 8.1 (64 bits)

The application pool is running with an Administrator account and the Enable 32-Bit Applications is set to True in Advance Settings.

The World Wide Web Publishing Service (W3SVC) has the Allow service to interact with desktop checked in the Properties.

Please let me know if anyone knows how to solve this. Thanks.

Community
  • 1
  • 1
Luis C.
  • 13
  • 1
  • 7
  • 1
    "not working" is not a valid description of the issue. What is the *exact* issue you're experiencing? If `AcroRd32.exe` has started but is not printing then it is an issue with Acrobat, not IIS or your program code and should be taken-up with Adobe support. – Dai Aug 03 '15 at 03:51
  • Why don't you capture the output of the process? See this: http://stackoverflow.com/a/285841/1623249 – Maria Ines Parnisari Aug 03 '15 at 04:06
  • To clarify, the issue is that the process is not finishing and the PDF is not printing. Also, I tried to execute a .bat file to discard that the issue is with Acrobat and got the same result. I did some tests capturing the process output like l19 suggested and the command is called correctly. Apparently the process is being executed but it never finishes. I added the .WaitForExit() and the web page never responded back. Is there anything else you suggest that I can try? Thank you very much for your help. – Luis C. Aug 05 '15 at 12:42

1 Answers1

0

Changed Acrobat Reader for Foxit Reader (https://www.foxitsoftware.com/products/pdf-reader/) and it solved the problem. The command line is very similar.

Luis C.
  • 13
  • 1
  • 7