Subject: Re: how do you set up a printer for NT v4

From: Brad Sileo <[email-masked]>
Date: Fri, 13 Sep 1996 14:54:23 -0600

At 03:52 PM 9/11/96 -0700, [email-masked] wrote:
>I tried to use the sample from the NT page at the U, but to no avail.  Has 
>anyone had any success setting up a printer and printing?  If so, how?  As 
>for my vital statistics, NT v4 OS, HP-682C printer.  Oh, and no problems 
>printing from other windoze applications.

Here is the LISP I use, though it is on NT v3.51, as long as the "print"
command is implemented in NT 4.0(I don;t have it to check), it should work
fine. BTW, this is not my code, though I did alter it a bit to use print
instead of lpr from its original form on this list.

As long as your printer is working correctly and you can print useing the
command line "print" command, this should work.  It ataches to the menu
options print buffer, postscript print buffer, etc..

-------- This goes in your .emacs or default.el file -------

;;; Setup printing for NT's using lpr.exe/NT-print.el
(setq lpr-command     "print"
      ps-paper-type   'ps-a4)

(defvar      lpr-destination    '("\\\\server\\printer")
  "*The UNC style location for regular print jobs\nThe default is
\\\\server\\printer.\nRemember to escape the backslashes(use '\\\\' for each
'\\') for emacs.")
(defvar      ps-lpr-destination '("\\\\server\\printer")
  "*The UNC style location for Postscript print jobs\nThe default is
\\\\server\\printer.\nRemember to escape the backslashes(use '\\\\' for each
'\\') for emacs.")

(load "print-NT"() t)

------- lisp file -- print-NT.el ----- put this in your EMACSLOADPATH
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; print-NT.el
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defvar ps-lpr-buffer "c:\\temp\\psspool.ps")
(defvar txt-lpr-buffer "c:\\temp\\psspool.txt")

;;;;;;; simple print

(defun print-lpr-buffer ()
	(shell-command
   (apply 'concat (append (list lpr-command " /D:")
                          lpr-destination
                          (list " " txt-lpr-buffer))))
	(delete-file txt-lpr-buffer)
)
(defun nt-print-buffer ()
  (interactive)
	(write-region (point-min) (point-max) txt-lpr-buffer)
	(print-lpr-buffer )
)
(defun nt-print-region ()
  (interactive)
	(write-region (point) (mark) txt-lpr-buffer)
	(print-lpr-buffer )
)

(define-key menu-bar-tools-menu [print-region]
  '("Print Region" . nt-print-region))
(define-key menu-bar-tools-menu [print-buffer]
  '("Print Buffer" . nt-print-buffer))

;;;;;;; ps-print 

(require 'ps-print)

(defun ps-print-lpr-buffer ()
	(shell-command
   (apply 'concat (append (list ps-lpr-command " /D:")
                          ps-lpr-destination
                          (list " " ps-lpr-buffer))))
	(delete-file  ps-lpr-buffer)
)

(defvar ps-print-use-faces nil
	"*Non-nil means alway print with faces.")

(defun toggle-use-face ()
	(interactive)
	(if ps-print-use-faces 
			(progn (setq ps-print-use-faces nil)
						 (message "ps-print-use-faces disabled"))
		(setq ps-print-use-faces t)
		(message "ps-print-use-faces unabled"))
)
(define-key menu-bar-tools-menu [toggle-use-face]
  '("Toggle on/off print-with-faces" . toggle-use-face))

(defun nt-ps-print-buffer ()
  (interactive)
	(if ps-print-use-faces 
			(ps-print-buffer-with-faces ps-lpr-buffer)
		(ps-print-buffer ps-lpr-buffer)
		)
  (ps-print-lpr-buffer)
)
(define-key menu-bar-tools-menu [ps-print-buffer]
  '("Postscript Print Buffer" . nt-ps-print-buffer))
(define-key global-map "\C-cp" 'nt-ps-print-buffer)

(defun nt-ps-print-region ()
  (interactive)
	(if ps-print-use-faces 
			(ps-print-region-with-faces (point) (mark) ps-lpr-buffer)
		(ps-print-region (point) (mark) ps-lpr-buffer)
		)
  (ps-print-lpr-buffer)
)
(define-key menu-bar-tools-menu [ps-print-region]
  '("Postscript Print Region" . nt-ps-print-region))
(define-key global-map "\C-crp" 'nt-ps-print-region)

;;;;;;;;;;
======================================================
                   Brad Sileo
              GeoData Solutions, Inc.		
Network Engineer                     GIS Consultant
Voice:(303)650-1600                 Fax:(303)650-1795 
             http://www.geodata-gis.com
======================================================