如何创建基于 Web 的打印服务器? [英] How do I create a web based print server?

查看:134
本文介绍了如何创建基于 Web 的打印服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于网络的订单调度系统.目前,系统用户手动打印发货单(即,他们在网络浏览器中选择打印").

I have a web based order dispatch system. At the moment, users of the system print out a dispatch note manually (ie, they choose "Print" in their web browser).

我想更新系统,以便所有打印都由一台专用机器处理.我希望它轮询服务器以查看是否有人需要打印某些内容,然后执行某些操作来打印它.我不太确定那东西需要是什么.

I would like to update the system so all the printing is handled by a single dedicated machine. I am expecting it to poll the server to see if anyone needs something printing, then do something to print it. I'm not too sure what that something needs to be.

例如.我可以有一个页面来检查新的打印作业并刷新自己并使用 javascript print() 函数,但这显然仍然需要有人按确定.有没有办法改变这种行为.它只需要在一台 PC 上运行,我就可以使用所需的任何选项和插件进行设置.

eg. I can have a page that checks for new print jobs and refreshes itself and uses the javascript print() function, but that obviously still needs someone to press ok. Is there a way to change this behavior. It only has to work on a single PC that I can set up with any options and plugins needed.

你们中的任何一个聪明的人都可以想出一个解决方案,让我更接近做我想做的事情.例如.有没有什么花哨的pdf工具可以从网上吸数据,填写文档并打印出来?

Can any of you bright sparks think of a solution that will allow me to get closer to doing what I want to do. eg. Is there a fancy pdf tool that can suck data off the web, fill in a document and print it?

推荐答案

如果我需要做的只是从 Linux 服务器打印,我会编写一个非常简单的 Web 服务,通过 POST 请求(来自主 Web应用程序,而不是来自用户的桌面),将其保存到一个临时文件中,并将其通过管道传输到可以直接接受 pdf 的 lpr 中.标准 Linux 打印系统可以轻松配置为打印到 Windows 或 Linux 打印服务器或联网打印机,而不是直接连接的打印机.

If all I needed to do was print from a Linux server, I would write a very simple web service that accepts pdf through a POST request (from the main web application, not from the user's desktop), saves it to a temporary file, and pipes it into lpr which can accept pdf directly. The standard Linux printing system can easily be configured to print to a Windows or Linux print server or a networked printer instead of a directly attached printer.

要实际生成 .pdf,如果您使用可填写的 pdf 表单,您可以使用 iText 填写字段 并保存结果,即使在 Acrobat Reader 中不允许您这样做.或者您可以使用 iText 从头开始​​生成整个 .pdf.我很喜欢使用 reportlab 在 Python 中生成 pdf.

To actually generate the .pdf, if you are using fillable pdf forms you can fill in the fields with iText and save the result even if you wouldn't be allowed to in Acrobat Reader. Or you could use iText to generate the whole .pdf from scratch. I've enjoyed using reportlab for pdf generation in Python.

如果出于某种原因您喜欢 XSLT,那么您可以使用 XSL-FO,但我认为这很痛苦.http://html2fo.sourceforge.net/ 将 html 转换为 XSL-FO,后者可以呈现为 pdf 和打印出来.

If for some reason you like XSLT then you could use XSL-FO but I think it's painful. http://html2fo.sourceforge.net/ converts html to XSL-FO which can be rendered to pdf and printed.

你到底在打印什么?您已经有pdf,还是需要将网页转换为pdf?如果您需要将网页精美地呈现为 pdf 那么 http://www.princexml.com/ 是一个商业解决方案.

What exactly are you printing? Do you already have pdf, or do you need to convert web pages to pdf? If you need to render web pages beautifully as pdf then http://www.princexml.com/ is a commercial solution.

这篇关于如何创建基于 Web 的打印服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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