用于在本地计算机上工作的Windows服务的打印机方法,但它在服务器中不起作用 [英] Printer method for windows service working in local machine but it is not working in server

查看:93
本文介绍了用于在本地计算机上工作的Windows服务的打印机方法,但它在服务器中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的打印机方法适用于所有带有Windows服务的office文件。这个方法的问题是,它在本地机器上工作,而不是在服务器上工作。我不知道原因但我想问题可能是微软办公室,因为它没有安装在服务器中,如果我错了请纠正我,我正在寻找解决方案来解决这个问题。有没有办法让方法在服务器上工作?任何建议将不胜感激



我尝试过:



这个是我的打印方法



The below printer method is working for all office files with windows service.The issue with this method was, it is working in local machine and is not working in server.I dont know the reason but I guess the problem might be with microsoft office, as it is not installed in server, Please correct me if I am wrong and I am searching for a solution to resolve this. Is there a way to make the method work in server? Any suggestion would be appreciated

What I have tried:

This is my method for printing

printJob = new Process();
                       printJob.StartInfo.FileName = filepath;
                       if (!string.IsNullOrEmpty(printerName))
                       {
                           printJob.StartInfo.Arguments = string.Format("{0} {1}", printerName, filepath);
                       }
                       printJob.StartInfo.UseShellExecute = true;
                       printJob.StartInfo.Verb = "print";
                       printJob.StartInfo.CreateNoWindow = true;
                       printJob.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
                       printJob.StartInfo.WorkingDirectory = Path.GetDirectoryName(filepath);
                       printJob.Start();
                       Message = Success;
                       return Message;

推荐答案

看起来好像你'正在使用Office进行打印。



非交互式环境(即Windows服务)不支持Office。
It appears as though you're using Office to do the printing.

Office is not supported in a non-interactive environment, i.e. Windows Services.


恭喜!根据您的问题的标题和代码片段,您试图在服务器端打印一些东西。也就是说,您可能希望打印机连接到在Web托管公司运行您的HTTP服务的机器上,并且托管公司的人员值班以支持此打印机并拿起您的纸张,并且他们发送这些纸张纸给你的顾客。有趣的想法,可能无法治愈。



-SA
Congratulation! According to the title of your question and the code fragment, you attempted to print something on the server side. That is, you probably hope that a printer is connected to the machine running your HTTP service at the Web hosting company, and the hosting company people stay on duty to support this printer and pick up your pieces of paper, and they send those sheets of paper to your customers. Interesting idea, and probably not curable.

—SA


这篇关于用于在本地计算机上工作的Windows服务的打印机方法,但它在服务器中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆