2

I would like to choose which printer is used for printing in Emacs. Before I can set printer-name to something, I need to know the names of the available printers. Under Windows, I can see the available printers in the "Devices and Printers" control panel, but that does not give me names I can use in Emacs. Under BSD or Linux I could use lpstat -d, but lpstat doesn't seem to be available in either Windows or the Cygwin command sets. cygcheck -p /lpstat only returns entries related to lpstat and not the tool its self. Is there another way to enumerate the available printers under Cygwin/Windows?

Windows 10 Professional Ver 10.0 Build 14393 emacs-w32 25.1-1

cira
  • 41
  • 3

1 Answers1

2

Well it turns out that the long-complicated-names-with-goobers listed in the "Devices and Printers" "Control Panel" / "Windows Settings" really are the printer names... ick.

(setq printer-name "Microsoft Print to PDF") M-x ps-print-buffer
does in fact generate a PDF file via Emacs.

The list of names in the "Control Panel" is confirmed by: cscript.exe prnmngr.vds -l and get-wmiobject -class win32_printer in PowerShell. get-printer also lists the printer names, but it truncates the long ones so it's useless.

Fortunately, printers can be renamed with rename-printer -name "HP Color LaserJet Pro MFP M477" -newname "hp477" in PowerShell, or through "Printer properties" in the GUI. (The printer must be on.)

Unfortunately, it seems that the built in printers, such as the Microsoft PDF printer, don't allow their lengthy names to be changed at all.

cira
  • 41
  • 3
  • 1
    How do you list the printers within cygwin? `cscript.exe prnmngr.vds -l` gives me an error about the ending .vds. – lucidbrot May 10 '17 at 06:56
  • I think this has been a coincidence. I have not seen specifying a printer name as `printer-name` work on Windows. – Michel de Ruiter Jan 14 '20 at 14:58
  • @lucidbrot -- 'cscript prnmngr.vds -l' is a windows command prompt thing. It doesn't work in the cygwin terminal. – cira Jul 18 '20 at 05:25
  • @Michel de Ruiter -- really? Mine doesn't work at all if the printer isn't in there. For some reason my "Microsoft Print to PDF" printer died. (every program that tries to use it freezes up) I installed CutePDF and used the ps-printer-name variable to fix it. (setq ps-printer-name "CutePDF Writer") So now I'm using ps-print-buffer to print. – cira Jul 18 '20 at 05:34