在java Web应用程序上打印服务 [英] Print service on java web application

查看:162
本文介绍了在java Web应用程序上打印服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Enterprise Java Web应用程序,可以从客户端 - 服务器应用程序迁移所有业务。因此,我需要调整所有要求,包括在每个客户端上打印(使用点阵/纯文本)。

I have an Enterprise Java web application that all of the business is migrated from client-server application. So I need to adapt all requirement including printing on every client (Using Dot Matrix / Plain text).

客户在分离客户端的打印要求是他们必须正确报告在完成该过程后,请打印一些系统信息。在客户端 - 服务器上很容易打印,但是当我迁移到Web应用程序时,我们使用嵌入到应用程序的服务器/小程序服务。因此,当客户端打开浏览器时,applet将被初始化。

Printing requirement for client on separated client is they must get the report right away after the process is finished, let say print some system information. On Client-server is easy just for printing, but when I migrate to web apps, we used Server/applet service that embedded to the apps. So the applet will be initialized when the client open the browser.

它有效但问题太多。有时applet会在没有客户端操作的情况下突然关闭,因此applet将自动从数据库中检查排队的报告。对于这种情况有什么建议吗?

It works, but too many issues. Sometime the applet is closed suddenly without action from client, so automatically the applet will be failed for checking the queued report from database. Is there any suggestion for this case?

我使用Spring Framework作为业务层。

I use Spring Framework as a business layer.

推荐答案

几年前我遇到了同样的问题。

I had the same problem years ago.

这就是我的所作所为。

This is what I did.

由于我的处理是在服务器上进行的,所以我知道交易完成的时间。所以我做的是直接从服务器发送打印请求。客户端打印机已在服务器中配置,因为它在LAN中使用,因此可以轻松访问。这样我完成了applet所遇到的所有问题,权衡是他们只能在办公室打印,但在我的情况下这很好,不一定适用于你,试一试。

Since my processing was taking place on the server, I knew when the transaction was finished. So what I did was to send the print request directly from the server. The client printer was configured in the server and since it was used in the LAN it could be easily reached. That way I finished with all the problems I had with the applet, the tradeoff was they can only print in the office, but in my situation that was fine, not necessarily applies for you, give it a try.

更新

在我的情况下,不同部门需要打印这个国家。

In my case, the print was needed by different departments along the country.

每个部门都有一个特定的,唯一的打印机用于该任务。所以我所做的就是将该打印机安装在服务器文件系统中(在Unix中类似于/ Volumes / printers / EPSON-12345,在Windows中为x:\ printers \ EPSON-12345)当用户在webapp中完成交易时我在服务器中启动打印请求。 Java根本没有任何问题要打印到本地打印机,并且由于映射的打印机被视为本地打印机(即使它是远程打印机),您不需要进一步的授权或任何特殊的。

Each department had an specific, unique printer for that task. So what I did was have that printer mounted in the server filesystem ( in Unix something like /Volumes/printers/EPSON-12345 , in Windows as x:\printers\EPSON-12345 ) When the user finished the transaction in the webapp I start in the server a print request. Java does not have any problem at all to print to a local printer and since a mapped printer is taken as local ( even though it is a remote one ) you don't need further authorizations or anything special.

由于我知道特定的打印机是映射的,我知道什么样的交易,我知道在哪里打印。

Since I knew what the specific printers were mapped, and I knew what kind of transaction that was, I knew where to print.

最后我使用属性文件允许打印机不时更改和/或添加更多打印机。

Finally I use a property file to allow the printer to change from time to time and/or add more printers.

我不太记得细节,但它有点像这在服务器中:

I don't quite remember the details but it was something like this in the server:

 ResourceBundle bundle = ResourceBundle.getBundle("printers");
 String serviceName    = bundle.getString("MEXICO.CITY.PRINTER");

 PrintService service = PrintService.find( serviceName );
 service.print( // document and etc );

但差不多4年了。以前所以我不记得确切的细节,但我的程序仍然在运行:)

But that was almost 4 yrs. ago so I don't remember exactly the details, but my program is still running :)

您可以在java 此处 。它比它看起来简单得多。

You can read more about the printing service in java here. It is way much simpler than what it look like.

这篇关于在java Web应用程序上打印服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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