15

The Emacs manual says:

M-x print-buffer

Print hardcopy of current buffer with page headings containing the file name and page number.

M-x lpr-buffer

Print hardcopy of current buffer without page headings.

M-x print-region

Like print-buffer but print only the current region.

M-x lpr-region

Like lpr-buffer but print only the current region.

[...]

To specify the printer to use, set the variable printer-name. The default, nil, specifies the default printer.

How do we specify the printer to use?

For example, a PDF printer, which is not shown in the output of

lpstat -p -d

Thanks.

1
  • You would need to install cups-pdf package, then follow the instructions here: wiki.archlinux.org/index.php/CUPS#PDF_virtual_printer (there isn't much to do, but be warned it is very likely that your user isn't allowed to print anything at all... CUPS is a fundamentally user-ugly system. So, you would need to log in as root (or find a way to make your user eligible for printer management, and no, it is not enough to be a sudoer). Then you can print just as you intended to. But (as I commented on your other question), PS and then ps2pdf will look nicer. – wvxvw Feb 18 '15 at 22:14
8

If you are on Linux you can install gtklp and set

(setq lpr-command "gtklp")
(setq ps-lpr-command "gtklp")

to give you a graphical print wizard. This doesn't actually give you print-to-file (unless you have a virtual pdf printer set up in CUPS), but it generally allows for easy printing from emacs.

3

The printing happens to the printer name set in the environment variable PRINTER.

For example:

  • I would first set the env var PRINTER to my-printer
  • Then launch emacs in that terminal
  • Then do M-x ps-print-buffer-with-faces
3
  • So you have to restart Emacs to select a different printer? – Supernormal Dec 7 '16 at 19:19
  • Ah, no: doing customize-apropos printer name lets you type in the name of the printer to use. – Supernormal Dec 7 '16 at 19:22
  • @Supernormal printer-name works if the user hasn't set the PRINTER env variable name, I believe, as per this... Note that the PRINTER env var gets the highest precedence. – Kaushal Modi Dec 7 '16 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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