【问题标题】:Is there any way to hold the print job using CUPS API?有没有办法使用 CUPS API 来保留打印作业?
【发布时间】:2016-08-05 12:17:29
【问题描述】:

有没有办法使用 CUPS API 来保持打印作业?我必须用 c 语言和 ubuntu 机器编写代码。一个例子真的很有帮助。

【问题讨论】:

    标签: c ubuntu cups


    【解决方案1】:

    查看 shell 命令 lprmcancel

    您可以使用 system()sh -c (How do I execute a Shell built-in command with a C function?) 从 c 调用 shell 命令

    http://linux.die.net/man/1/lprm-cups https://www.cups.org/documentation.php/man-cancel.html

    http://linux.die.net/man/3/system

    另见http://www.g-loaded.eu/2005/11/10/using-a-cups-printer-from-command-line/(命令可与system()sh -c一起使用)

    你也可以用这个,用shell命令更方便: cupsCancelJob()

    #include <cups/cups.h>
    
    cups_dest_t *dest;
    int job_id;
    
    cupsCancelJob(dest->name, job_id);
    

    如果您想删除作业(同时停止打印),请使用 cupsCancelJob2()

    ipp_status_t cupsCancelJob2 (
        http_t *http,
        const char *name,
        int job_id,
        int purge
    );
    

    参数

    http 连接到服务器或 CUPS_HTTP_DEFAULT

    名称 打印机或类的名称

    job_id 当前工作的工作 ID、CUPS_JOBID_CURRENT 或所有工作的 CUPS_JOBID_ALL

    清除 1 清除,0 取消

    https://www.cups.org/documentation.php/doc-2.0/api-cups.html#cupsCancelDestJob

    【讨论】:

    • 实际上我必须先持有工作,在监控工作后,管理员将决定是否取消或释放工作。我使用 cupsGetJobs API 获取工作 ID,但工作没有持有。一旦用户发出打印命令,打印机就会启动。我希望你明白我在尝试什么。帮助我......
    • cancel 命令从打印队列中删除作业,因此它们无法重新启动askubuntu.com/questions/350334/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-24
    • 1970-01-01
    • 2021-03-07
    相关资源
    最近更新 更多