有人知道使用 CUPS API
获取打印机 URI 吗?
如果没有,有谁知道我在哪里可以找到可以传递给 cupsGetOption 函数
的允许选项列表。
现在我只能找到printer-info, printer-location, printer-make-and-model
。
最佳答案
您可能正在寻找的是“device-uri”。这是远程设备的 uri,即 lpd/socket/server 地址。如果您正在寻找本地 uri,它将是“printer-uri-supported”,这将导致 ipp://localhost:631/printers/printername。这是获取远程 uri 的方法...
#import <cups/cups.h>
const char * printer = "name_of_printer";
int num_dests;
cups_dest_t *dest,
*dests;
const char *value;
num_dests = cupsGetDests(&dests);
dest = cupsGetDest(printer, NULL, num_dests, dests);
if( dest == NULL){
return 0;
};
value = NULL;
if (dest->instance == NULL)
{
value = cupsGetOption("device-uri", dest->num_options, dest->options);
}
cupsFreeDests(num_dests, dests);
printf("uri - %s",value);
关于objective-c - 如何使用 CUPS 查找打印机 URI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17662355/