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

1 Answer 1

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.

4
  • 1
    How do you list the printers within cygwin? cscript.exe prnmngr.vds -l gives me an error about the ending .vds.
    – lucidbrot
    Commented May 10, 2017 at 6:56
  • I think this has been a coincidence. I have not seen specifying a printer name as printer-name work on Windows. Commented Jan 14, 2020 at 14:58
  • @lucidbrot -- 'cscript prnmngr.vds -l' is a windows command prompt thing. It doesn't work in the cygwin terminal.
    – cira
    Commented Jul 18, 2020 at 5: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
    Commented Jul 18, 2020 at 5:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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