The topic of this page is printing from within Emacs. This includes printing Emacs buffers and regions. It includes printing using different operating systems, color printing, etc.
Emacs comes with libraries
ps-print.el, but they are not preloaded.
ps-print.el(PsPrintPackage) provide printing commands for use with text and PostScript printers. This includes color printing and printing using the highlighting (faces) you see in Emacs itself.
printing.elis an extension of library
ps-print.elthat provides a complete set of highly customizable menus and commands for all kinds of printing from within Emacs. It lets you easily print using different printers and different operating systems (e.g. Windows, Unix, Linux). It lets you preview printing with ghostview. Library
printing.el(PrintingPackage) is available from ViniciusJoseLatorre. (DrewAdams recommends library
For those who wish to print on a local printer when running emacs through an ANSI terminal or alike (eg PuTTY), there is ansi-lpr (http://lists.gnu.org/archive/html/gnu-emacs-sources/2005-03/msg00007.html) (a library whose code length is less than its licence!). It allows users to print using the familiar commands (
‘print-region’) provided by lpr.el.
N.B. When downloading the library, make sure the control characters are still there – Matthias.
A way to easily print documents on Microsoft Windows is to add the following forms to your Emacs InitFile:
(setenv "GS_LIB" "e:/tools/GSTools/gs8.14/gs8.14/lib;e:/tools/GSTools/gs8.14/fonts") (setq ps-lpr-command "e:/tools/GSTools/gs8.14/gs8.14/bin/gswin32c.exe") (setq ps-lpr-switches '("-q" "-dNOPAUSE" "-dBATCH" "-sDEVICE=mswinpr2")) (setq ps-printer-name t)
You have to change the paths to reflect the actual directories on your system. The
setenv form might not be necessary if
GS_LIB is already set in the underlying environment.
This requires Ghostscript, but no extra Emacs library. You can print as usual with the “ps-print” commands. A pop-up will ask for the printer to send the output to.
Unfortunately, you should read the section Adware toolbar controversy on the Wikipedia page before installing it. :sucks:
If you decide to install it anyway, PDFCreator is a version of ghostscript & ghostview that acts like a windows printer driver. It allows you to create PDF’s from any windows application that will let you print.
You can tune the PDFCreator to do all sorts of things, I have it set to autosave the PDF and open it in Acrobat. Most Windows Emacsians have cygwin installed, this uses the cygwin version of lpr. To set Emacs up to use it add the following to your InitFile:
(setenv "PRINTER" "PDFCreator") (cond ((eq system-type 'windows-nt) (setq ps-printer-name "PDFCreator") (setq ps-printer-name-option "-d") (setq ps-lpr-command "/bin/lpr"))) ; if you're using the Emacs in Cygwin ;(setq ps-lpr-command "c:/cygwin/bin/lpr.exe"))) ; if you're using the native Windows build of Emacs
To test use ps-print-buffer. – TimOCallaghan
See PrintCommandQuotes for a work-around.