Reputation: 624
I have a Linux PC with CUPS and a printer connected to it. Is it possible to get a PostScript document that CUPS driver generates and sends to the printer when I create a print job?
Upvotes: 1
Views: 1552
Reputation: 90263
The comment advising you to stop the print queue and fetch the jobfile from /var/spool/cups/
falls short:
Now the received file MAY already be in PostScript format (if the printing application was, say, Firefox). But it can also be any format accepted by CUPS (text, image, PDF or "raw" input formats). Even if it is PostScript, CUPS will still somewhat process it before it sends it off to the print device. The amount of processing depends on the definite job options requested by the user.
To really intercept the exact same bytestream that would be sent to the printer by a CUPS queue can be a bit more work (as my StackOverflow answer linked shows).
However, you may be lucky by trying the following steps:
FileDevice Yes
into your cupsd.conf. (Stop your CUPS service and restart it after you edited the configuration file.)Take note of your current "backend" URI for the print queue you want to intercept by running:
lpstat -v
(This is only to make sure that you can later restore it to the same working state as before.)
Modify your existing CUPS queue by running
lpadmin -p printername -v file:/var/spool/cups/tmp/ps-test.ps
Now your queue is disconnected from its real device URI and "connected" to the "file" device. It will now store all processed print jobs in the location /var/spool/cups/tmp/ps-test.ps. (You may need root privileges to scrap it off or read it there.)
You'll be more "unlucky" if your CUPS version is rather recent. There the FileDevice
configuration parameter has been removed due to security considerations.
Upvotes: 3