0

Is there any way to hold the print job using CUPS API ? i have to code in c language and on ubuntu machine.An example could really help.

Mr. India
  • 1
  • 5

1 Answers1

0

see the shell commands lprm and cancel

You can invoke shell commands from c using system() or sh -c (How do I execute a Shell built-in command with a C function?)

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

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

Also see this http://www.g-loaded.eu/2005/11/10/using-a-cups-printer-from-command-line/ (commands can be used with system() or sh -c)

You can also use this, it is easier to use the shell commands: cupsCancelJob()

#include <cups/cups.h>

cups_dest_t *dest;
int job_id;

cupsCancelJob(dest->name, job_id);

If you want to delete the job (also stops printing) use cupsCancelJob2()

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

Parameters

http Connection to server or CUPS_HTTP_DEFAULT

name Name of printer or class

job_id Job ID, CUPS_JOBID_CURRENT for the current job, or CUPS_JOBID_ALL for all jobs

purge 1 to purge, 0 to cancel

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

Community
  • 1
  • 1
ralf htp
  • 9,149
  • 4
  • 22
  • 34
  • actually i have to hold the job first and after monitoring the job ,the admin will decide whether to cancel or release the job.I am getting the job id using cupsGetJobs API but the job is not holding.As soon as user gives print command the printer gets on.I hope you you unserstand what i m trying to so.Help me... – Mr. India Apr 14 '16 at 06:17
  • The `cancel` command removes jobs from print queue so they can not be restarted http://askubuntu.com/questions/350334/how-do-i-clear-a-print-queue-in-ubuntu – ralf htp Apr 14 '16 at 06:27