这是通过 CUPS 获取纸张大小的最佳方法吗?
我有一个 CUPS 作业控制文件(可以在 /var/spool/cups/cnnnnn 找到)。我需要获得所制作印刷品的实际尺寸。
这是我想出的方法:
- 使用
media
属性获取论文名称。 (例如Letter
) - 从
printer-uri
属性获取打印机uri。 (例如ipp://localhost/printers/MyPrinter
) - 通过将打印机 uri 传递给
IPP_GET_PRINTER_ATTRIBUTES
操作并获取printer-name
来获取打印机名称代码>属性。 (例如MyPrinter
) - 获取PPD 的路径,将打印机名称传递给
cupsGetPPD
方法。 - 打开 PPD,将 PPD 的路径传递给
ppdOpenFile
方法。 - 通过将 PPD 和纸张名称传递给
ppdPageSize
方法来获取纸张尺寸。
这会起作用,但似乎有点迂回。有没有更有效的方式来获取我需要的东西?
I've got a CUPS job control file (these can be found at /var/spool/cups/cnnnnn). I need to get the actual dimensions of the print that was made.
This is the way I've figured out to do it:
- Get the paper name using the
media
attribute. (e.g.Letter
) - Get the printer uri from the
printer-uri
attribute. (e.g.ipp://localhost/printers/MyPrinter
) - Get the printer name by passing the printer uri to the
IPP_GET_PRINTER_ATTRIBUTES
operation and getting theprinter-name
attribute. (e.g.MyPrinter
) - Get the path to the PPD passing the printer name to the the
cupsGetPPD
method. - Open the PPD passing the path to the PPD to the
ppdOpenFile
method. - Get the paper size by passing the PPD and paper name to the
ppdPageSize
method.
This will work, but it seems a bit roundabout. Is there a more efficient way of getting what I need?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
作业控制文件将包含用于打印的文件的所有作业选项。有 3 种类型的作业选项:
~/.lpoptions
或系统范围的/etc/cups/lpoptions
文件(用户在较新版本的 CUPS 中,特定文件已迁移到~/.cups/lpoptions
(这些文件也将出现在控制文件中);如果您知道 printqueuename 和使用的 cupsserver,则可以使用这两个命令查询该组合的默认队列设置:
这将返回所有内容。
(.)loptions
文件中注明的当前设置。这将返回 PPD 中包含的所有用户可选设置。请注意星号
*
如何标记默认设置。每个选项的设置。另请注意,-U username
在这里很重要 - 不同的用户可能使用不同的默认设置...现在请注意这些命令的结果,注意所使用的
PageSize
。 。The job control file will contain all the job options of the file used for printing. There are 3 types of job options:
~/.lpoptions
or a system-wide/etc/cups/lpoptions
file (the user specific file has been migrated to~/.cups/lpoptions
in more recent versions of CUPS (these ones will also appear in the control files);-o job-hold-until=indefinite
.If you know the printqueuename and the cupsserver used, you can query the default queue settings for that combo with these two commands:
This will return all current settings as noted in the
(.)loptions
file(s).This will return all user-selectable settings contained in the PPD. Note how the asterisks
*
marks the default setting for each option. Also note that-U username
is significant here -- different users may use different default settings...Now watch out for the results of these commands noting the
PageSize
used...实际上,您可以使用 CUPS_GET_PPD 请求直接获取 ppd,而不是执行步骤 3 和 4。这似乎更有效。
You can actually use the CUPS_GET_PPD request to get the ppd directly instead of steps 3 and 4. This seems more efficient.