Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When you select "Print to File" in a Gnome print dialog (not cups-pdf):


... what is the actual command that gets executed? (I'm interested in the postscript variant, as on the image)

On the other hand - maybe there isn't a command call; maybe it is gtk_print_operation_set_export_filename from The new Gtk+ Printing API?

In any case - is there a way for me to utilize this particular code from the command line (not pdf2ps and the like)? Say, by using lpr to "print to file" to a postscript file - as if I was using the dialog above?

share|improve this question
AFAIK, this is a feature of the subsystem used by some GNOME and GTK+ applications to print stuff (some of these use Cairo). lpr interacts with cups directly, the print to file option completely bypasses the printing server. it probably doesn't call a command, it just invokes the cairo renderering function in a different way so it generates pdf, postscript or svg output to a file. –  njsg Jun 7 '12 at 21:27
Ah, so its the cairo backend there! Any ideas if a comparable command line is available, that can invoke this rendering function in the same way as the print dialog does? Many thanks for the comment, @njsg - cheers! –  sdaau Jun 7 '12 at 22:39
There may be some cairo command line tool (I really don't know), but I guess it's a bit tricky, as many applications use cairo to print their own documents, and that application is the one which is able to understand the file format. Cairo won't be able to read random file formats. The closest you can get is to check if the program with the dialog has some commandline option to print a file without opening the GUI. –  njsg Jun 7 '12 at 23:15
Thanks for explaining that @njsg - the above screenshot was taken from the evince print dialog; unfortunately, I cannot see any command line switches by evince that would do something like this.. Cheers! –  sdaau Jun 7 '12 at 23:18
This is just an UI convention, each program can in principle do what they wish when "Print to file" is selected. –  vonbrand Jan 15 '13 at 15:18

2 Answers 2

lpr -P "Print_to_PDF" file_to_print

To get the list of currently configured printers, run lpstat -p -d.

share|improve this answer

You could use the cups-pdf package as a solution independent from gnome. After installing the package, add the PDF printer using the cups webinterface at http://localhost:631 as described here ('General' as printer manufacturer, CUPS-PDF as driver).

For your convenience, change the output directory with the option Out in /etc/cups/cups-pdf.conf to, like, ${HOME} or sth. Then do as suggested by @Noam to print to file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.