The document is printed without any problems during manual start, for the same user who was assigned to SQL Server via EXEC command sp_xp_cmdshell_proxy_account user, pass . Application code that causes printing:

public static bool PrintPdFs2(string pdfFileName, System.Drawing.Printing.PrinterSettings printersettings) { try { var p = new Process { StartInfo = { FileName = pdfFileName, WindowStyle = ProcessWindowStyle.Hidden, Verb = "PrintTo", Arguments = "\"" + printersettings.PrinterName + "\"", CreateNoWindow = true } }; p.Start(); p.WaitForExit(8000); p.Kill(); return true; } catch (Exception e) { Logger.Error(e); return false; } } 

I checked the incoming parameters, they are correct, the correct path to the file is indicated, and the printer you need comes in. I also see that in the process of invoking this command, Adobe Reader DC is launched on the server side, which means that the process is still running. Checked the file that it prints, it is not empty. Please advise what else you can do?

UPDATE

I'll tell you about how I solved the problem, how little it will be useful to someone and will save time, because I personally killed this case for almost 8 hours. When you enter a user in sp_xp_cmdshell_proxy_account, you specify with what rights to run the application, it is launched on behalf of the user specified in the configuration of the sql server itself.

I went on the wrong path deciding that the problem is that the user from whom the application is running does not have rights or something else there, because To see what was happening on his side was not possible (as the admins told me, he does not have his own workspace), then I had the task to try to launch this application on behalf of another user. The task is not trivial, but I found a way how to do it, use the psexec application, though it can only run the application located on a different server. What was my disappointment when after several hours I was able to launch the application from under the user that I need and the printing never went ...

In general, after playing with a tambourine with the launch of the application from under another user, I decided to find alternatives to standard printing with the help of third-party products that have the ability to print pdf files. And I found it in pdfium, just install the latest version, otherwise you will have to install the additional module (I put 2.10.0), plus there are additional settings for this module, read.

In general, the question of why a document is not printed by the standard method is open, but if you need a workaround method, use pdfium.

  • Is the file on the server or on a network resource? - Denis Rubashkin
  • Yes, the file is located next to the executable file on the server. Now it turned out that Adobe Reader DC runs from under a different user, some sql_start, I don’t understand where it came from, maybe there’s a problem? - MiXaiL
  • Most likely in him, apparently he does not have enough rights - Denis Rubashkin

0