在网络打印机上无人值守打印文档
我们正在尝试将主文档(在自动邮件合并之后)以自动方式发送到我们的一台网络打印机,该打印机同时分配了网络名称和内部 IP。
但这是真正棘手的部分。当我们从工作站打印文档时,我们确实会收到“作业会计”对话框提示,在打印之前输入该文档所属的项目代码,以便财务部门可以完成所有精美的会计和计费工作。
那么,我们如何以编程方式将文档 (docx) 连同作业统计参数一起发送到网络打印机呢?
我不确定在执行打印作业时会计数据有多常见,因为这是我第一次看到它。
以下是重要的细节:
- PHP 5(首选)
- Windows Server(2003 年,我相信)
- Kyocera KM-4050 打印机(带静态 IP)
- C++ 和 Visual Basic 的一些经验
我们已经做了一些研究,但还没有发现太多在野外寻找可行的解决方案,经过一番讨论后,我们并不完全确定从哪里开始。不幸的是,似乎没有任何类型的 API 我们可以插入。
----- 解决方案 -----
我的团队决定实现代码,该代码将调用可执行文件以将每个文档转换为 PCL,然后获取生成的 PCL 并在其前面加上
@PJL SET KJOBMANAGERCODE="[project code here]"
然后我们将获取生成的文件并将其写入打印机假脱机,打印机将在其中处理它并启动每个作业。
谢谢大家的帮助。每个答案几乎都启发了我们实施计划的某个部分。
We're trying to have a master document (after an automated mailmerge) be sent, in an automated fashion, to one of our network printers which has both a network name and internal IP assigned.
But here's the really tricky part. When we print a document from our workstations we do get prompted with a 'Job Accounting' dialog to enter the project code that the document is for before it'll print, so the finance department can do all their fancy accounting and billing stuff.
So, how do we send a document (docx) to a network printer along with the Job Accounting parameter programmatically?
I am not sure how common accounting data is when doing print jobs, as this is the first job I've ever seen it.
Here are the important specifics:
- PHP 5 (preferred)
- Windows Server (2003, I believe)
- Kyocera KM-4050 Printer (w/ static IP)
- Some experience with C++ and Visual Basic
We've done some research but haven't found too many viable solutions out in the wild and after some discussion, we're not entirely sure where to start. Unfortunately, there does not appear to be any kind of API we can plug into.
----- SOLUTION -----
My team has decided to implement code that will call an executable file to convert each document to PCL and then to take the generated PCL and prepend it with
@PJL SET KJOBMANAGERCODE="[project code here]"
Then we will take the generated file and write it to the printer spool where the printer will process it and start each job.
Thank you all for your help. Each answer pretty much inspired a certain part of our implementation plan.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我要做的是:
现在一切都取决于您的 VB/ C++ 编程技能 :) 顺便说一句:另一个选项是您可以使用 VBScript/C++ 的 exec() 和 CLI 参数,而不是将文件保存到目录。但基于文件的解决方案更加健壮,因为它是一种自然队列,并且还可以抵抗打印程序故障 - 作业仅在完成后才会被删除。如果打印作业失败,它将在下次尝试。可以使用数据库来类比文件,但我不确定从 VB/C++ 连接到数据库有多容易,因此文件系统是最好的后备;)
PHP 部分只有一个指向将保存 JA ID 的脚本的链接和文件名到 /path/infos/ 中的文件,
这是一种解决方案,但我认为不值得在纯 PHP 中执行此操作(使用 PHP 扩展)。
What I would do is:
Now everything depends on your VB/C++ programing skills :) BTW: the other option is instead of saving files to directory you can use exec() and CLI params for the VBScript/C++. But the file-based solution is more robust, as it's kind of a natural queue and it's also resistant to the print program failures - the job is only removed when it'S completed. If the print job fails, it will try that the next time. Analogy to the files can be done using database, but I'm not sure how easy is to connect to DB from VB/C++ so the filesystem is best fallback ;)
The PHP part is only having a link to script that will save JA ID and filename to a file in /path/infos/
It's kind of a workaround solution, but I don't think it's worth to do it in pure PHP (using an PHP extension).
“作业统计”只是重新命名用户名/密码提示的驱动程序。
如果您提到您正在使用什么操作系统来托管 PHP 以及您的用户在哪里遇到这些提示,这将会很有帮助 - 但我认为很明显您正在使用 MSWindows 来执行这两种操作。
简而言之,您需要绕过该对话框 - 该对话框(当前)内置于您的打印机驱动程序中)。可以配置打印机驱动程序,或者您可以使用替代打印子系统,例如 Cups。
'Job accounting' is just the driver rebranding the username/password prompt.
It would be helpful if you'd mentioned what operating system(s) you're using for hosting PHP and where your users experience these prompts - but I think its fairly obvious that you are using MSWindows for both.
Short answer is that you need to bypass the dialog - which is (currently) built into your printer driver). It may be possible to configure the printer driver, or you could use an alternative printing subsystem such as Cups.
如果您希望它使用 PHP,则传递 PJL 参数(会计所需)并不容易实现(当然,据我所知)。但是您可以使用套接字连接来传递您喜欢的任何参数以及要打印的相关文档。示例:
上面的示例来自 IronGeek 博客,他有一篇有趣的介绍性文章,介绍如何编写自己的连接来控制网络打印机。然而,我首先会嗅探打印作业中计算机和网络打印机之间发送的流量,以便更好地了解所涉及的确切命令 - 这应该使该协议可以通过 PHP 上的套接字连接轻松实现。
If you want it to use PHP, passing PJL parameters (needed for the accounting) is not easily achievable (AFAIK of course). But you may use a socket connection to pass any parameter you like, along with the document in question to print. Example:
The above example is from the IronGeek Blog, who has an interesting introductionary article on coding your own connection to control network printers. However, I would start by sniffing the traffic send between your computer and the network printer on a printjob to get a good look at the exact commands involved - this should make the protocol easily implementable via a socket-connection over PHP.
我的团队决定实现代码,该代码将调用可执行文件以将每个文档转换为 PCL,然后获取生成的 PCL 并在其前面添加
@PJL SET KJOBMANAGERCODE="[此处的项目代码]"
然后我们将获取生成的文件并将其写入打印机假脱机,打印机将在其中处理它并启动每个作业。
谢谢大家的帮助。每个答案几乎都启发了我们实施计划的某个部分。
My team has decided to implement code that will call an executable file to convert each document to PCL and then to take the generated PCL and prepend it with
@PJL SET KJOBMANAGERCODE="[project code here]"
Then we will take the generated file and write it to the printer spool where the printer will process it and start each job.
Thank you all for your help. Each answer pretty much inspired a certain part of our implementation plan.