使用 CUPS 打印,我的应用程序什么时候可以退出?

发布于 2024-07-05 12:41:36 字数 369 浏览 4 评论 0原文

我有一个使用cups进行打印的Linux应用程序,但我注意到,如果我打印然后立即退出我的应用程序,我的打印输出永远不会出现。 所以我假设我的应用程序必须等待它真正从打印机中出来后再退出,所以有人知道如何判断它何时完成打印吗?

我正在使用 libcups 打印我的应用程序生成的 postscript 文件。 因此,我使用该命令打印文件,然后它返回到我的应用程序。 因此,当我猜测文档尚未到达打印机队列时,我的应用程序认为该文档已进入打印机队列。 因此,与其让我的所有用户都必须在屏幕上查找系统托盘中的打印机图标,我宁愿在代码中提供解决方案,因此,如果他们在真正发送之前尝试退出,我可以提醒他们这一事实。 另外,我生成的文件是一个临时文件,因此很高兴知道它何时完成,以便我可以将其删除。

I have an linux app that uses cups for printing, but I've noticed that if I print and then quit my app right away my printout never appears. So I assume that my app has to wait for it to actually come out of the printer before quitting, so does anyone know how to tell when it's finished printing??

I'm using libcups to print a postscript file that my app generates. So I use the command to print the file and it then returns back to my app. So my app thinks that the document is off to the printer queue when I guess it has not made it there yet. So rather than have all my users have to look on the screen for the printer icon in the system tray I would rather have a solution in code, so if they try and quit before it has really been sent off I can alert them to the fact. Also the file I generate is a temporary file so it would be nice to know when it is finished with so I can delete it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

三生殊途 2024-07-12 12:41:37

一旦您的 CUPS Web 界面 (localhost:631) 或其他查看 CUPS 看到的内容显示 CUPS 收到了作业,您就可以退出该应用程序。

As soon as your CUPS web interface (localhost:631) or some other thing to look at what CUPS sees shows you that CUPS received the job, you can quit the application.

浅忆 2024-07-12 12:41:37

使用像 lpr & 这样的打印后台服务怎么样? lpq

How about using a print spool service like lpr & lpq?

青春有你 2024-07-12 12:41:37

您当然不需要等到纸张从打印机中取出。 但是,您需要等待 cupsd 在其假脱机区域(通常为 /var/spool/cups/)完全接收临时文件。

如果您在命令行上打印(使用 CUPS lplpr 命令之一),如果 shell 提示符返回(该命令甚至会报告发送的作业的 CUPS 作业 ID),以及退出代码 ($?) 是否为 0。

您没有指明您正在使用 libcups 的哪一部分以及哪个函数调用来实现您想要的目的。 如果我必须这样做,我会使用 IPP 函数 cupsSendRequest 然后 cupsGetResponse 了解结果。

You certainly do not need to wait till the paper is out of the printer. However, you need to wait until your temporary file is fully received by cupsd in its spooling aerea (usually /var/spool/cups/).

If you printed on the commandline (using one of the CUPS lp or lpr commands) you'd know the job is underway if the shell prompt returns (the command will even report the CUPS job ID for the job sent), and if the exit code ($?) is 0.

You do not indicate which part of libcups and which function call you are using to achieve what you want. If I'd have to do this, I'd use the IPP function cupsSendRequest and then cupsGetResponse to know the result.

风向决定发型 2024-07-12 12:41:37

当您退出时,您的应用程序可能尚未完成打印。 如果您使用 evince 打印 PDF 或其他文档,这是一个已知错误 - 没有视觉确认打印操作正在进行。 如果打印作业已提交,打印机图标将出现在系统托盘中,直到实际打印完成。 您可以单击系统托盘中的打印机图标,查看当前正在运行和待处理的作业。

Your app likely hadn't finished printing yet when you quit it. If you're using evince to print a PDF or other document, this is a known bug--there is no visual confirmation that the printing operation is underway. If the print job has been submitted, a printer icon will appear in your system tray until the actual printing has finished. You can click on the printer icon in the system tray and see what jobs are currently running and pending.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文