<p>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??</p>

<p>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.</p>

[{'answer_id': 76813, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>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.</p>\n"}, {'answer_id': 82209, 'author': 'Paweł Hajdan', 'author_id': 9403, 'author_profile': 'https://Stackoverflow.com/users/9403', 'pm_score': 1, 'selected': False, 'text': '<p>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.</p>\n'}, {'answer_id': 190892, 'author': 'hendry', 'author_id': 4534, 'author_profile': 'https://Stackoverflow.com/users/4534', 'pm_score': 1, 'selected': False, 'text': '<p>How about using a print spool service like <code>lpr</code> &amp; <code>lpq</code>?</p>\n'}, {'answer_id': 3022250, 'author': 'Kurt Pfeifle', 'author_id': 359307, 'author_profile': 'https://Stackoverflow.com/users/359307', 'pm_score': 1, 'selected': False, 'text': '<p>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 <code>/var/spool/cups/</code>).</p>\n\n<p>If you printed on the commandline (using one of the CUPS <code>lp</code> or <code>lpr</code> 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 (<code>$?</code>) is 0.</p>\n\n<p>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 <a href="http://www.cups.org/documentation.php/doc-1.4/api-httpipp.html#cupsSendRequest" rel="nofollow noreferrer"><code>cupsSendRequest</code></a> and then <a href="http://www.cups.org/documentation.php/doc-1.4/api-httpipp.html#cupsGetResponse" rel="nofollow noreferrer"><code>cupsGetResponse</code></a> to know the result.</p>\n'}]
['https://Stackoverflow.com/questions/76637', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/13676/']