Saving a pending print job as PDF

I printed an important receipt and quit Safari, only to learn the job never printed because we no longer own the network printer the computer was expecting to find. Thus, the only remaining copy of this information is in the print queue.

How do I salvage the information waiting to be printed so I can use it again?

Note: Dragging the enqueued item from the non-existant printer's queue to an existant printer's queue will print the item. I would like to know how to save the file waiting to be printed so it can be used again.


Solution 1:

The CUPS web interface would allow you to direct the print job to another printer.

However it's possible to capture a PDF file from the CUPS queue:

/private/var/spool/cups  
total 472  
drwx--x---  24 root  _lp      816 Mar  1 14:30 ./  
-rw-------   1 root  _lp     4403 Mar  1 14:30 c00025  
drwxrwxr-x  13 root  _lp      442 Mar  1 14:30 cache/  
-rw-r-----   1 root  _lp    86110 Mar  1 14:28 d00025-001  
drwxrwx--T   5 root  _lp      170 Mar  1 14:28 tmp/  
-rw-------   1 root  _lp     4391 Feb 25 12:13 c00024  
root@Macbook: file d00025-001
d00025-001: PDF document, version 1.3

You can copy (in this example) d00025-001 to somewhere and rename it with a pdf extension (n this case), after fixing permissions, ownership and group you can open it.

The matching file starting with c is the cover sheet. You should be able to recover the job in the the printers native language from the tmp directory:

/var/spool/cups/tmp
total 288
drwxrwx--T   5 root  _lp     170 Mar  1 14:34 ./
drwx--x---  28 root  _lp     952 Mar  1 14:50 ../
-rw-r-----   1 root  _lp    1234 Mar  1 14:28 17ed254faebef
-rw-r-----   1 root  _lp    1193 Mar  1 14:34 17ed254fece74
-rw-------   1 root  _lp  136512 Mar  1 14:28 17f025500d2e2
david_koontz@Macbook: file *2
17f025500d2e2: PostScript document text conforming DSC level 3.0, Level 2

This all done with an aging HPLJ-5000N LaserJet specified as a PostScript printer, the print job one page out of an ODT file (OpenOffice).

The original (in this case ODT) file isn't kept in the print system, which would force you to format it again.

Solution 2:

To find and retrieve the print jobs:

Use the go to Folder in Finder and paste this /private/var/spool/.

Now right- Click on the CUPS folder and use Get Info to change the permission.

If you have files waiting to be printed then it looks like this:

enter image description here

It is the file name beginning with "d" that you want to copy.

Solution 3:

At some point the default for saving print jobs was changed in OS X. Likely it was earlier in El Capitan, but as of 10.11.6 I'm seeing the "d0000" files noted above are not saved once a job prints anymore. You can return this functionality by typing in Terminal

sudo cupsctl PreserveJobFiles=Yes

Upon doing this the "d" file matching the "c" file will be saved in /var/spool/cups exactly as described above. This file can be copied to your Desktop but if you want to view it you first need to add the .zip extension and unzip it and then you can add .pdf to the unzipped file of the same name and it can be viewed. Nothing like making an admin's job easy [!]

Solution 4:

In Finder, from the Go menu in the menubar (the right click menu of Finder in the Dock) select Go to Folder... (G).

Paste in /private/var/spool/ and hit Go.

The print jobs are the files beginning with "d". Copy them and rename them to end in .pdf.