최근 편집
요약: Added a bash script for nup -n2 style printing.
추가됨:
> And here's a bash script to print two pages per sheet with no margin, 80 chars/line:
> #!/bin/bash
> if [[ $# != 1 ]]; then
> echo "usage: $0 FILE" > /dev/stderr
> exit 2
> fi
> in="$1"
> out="/tmp/$(basename "$in").ps"
> emacs \
> --quick \
> --file "$in" \
> --eval "
> (let ((ps-top-margin 0)
> ;; adjust this and font size if enabling line numbers
> (ps-left-margin 0)
> (ps-right-margin 0)
> (ps-inter-column 0)
> (ps-landscape-mode t)
> (ps-number-of-columns 2)
> ;; 80 chars per line
> (ps-font-size 8.25)
> ;; (ps-line-number t)
> (ps-line-number-font-size 10)
> (ps-line-number-step 10)
> (ps-print-color-p 'black-white))
> (ps-print-buffer-with-faces \"$out\")
> ;; gives chars per line info, among other things
> ;; (ps-line-lengths)
> ;; (write-file \"/tmp/line-lengths.txt\")
> (kill-emacs))
> "
> echo "$in -> $out"
Use M-x ps-print-buffer or M-x ps-print-region to print to a PostScript printer.
Here is a setup to print two pages on an A4 paper:
;; 2 column landscape size 7 prints column 0-78, lines 1 to 70
(setq ps-paper-type 'a4
ps-font-size 7.0
ps-print-header nil
ps-landscape-mode t
ps-number-of-columns 2)Here is how to add a network printer when using Emacs on Windows:
(setq ps-lpr-command "print" ps-printer-name "//FS_BSI1/HL-1270" printer-name "//FS_BSI1/HL-1270")
If you want to print international characters, and you printer does not have the necessary InternationalFonts, you might get the GNU intlfonts package and try PrintingBdfFonts.
Now you can use ‘M-x ps-print-buffer’, ‘M-x ps-print-buffer-with-faces’, ‘M-x ps-print-region’, and ‘M-x ps-print-region-with-faces’. Use the C-u prefix to save the PostScript code into a file instead of printing it.
Note that “print” ps-lpr-command does not work in XEmacs. Try generic-print-buffer instead. See the ps print manual for more information.
See Also: library printing.el at PrintingPackage. This library uses library ps-print.el (PsPrintPackage). It provides a user-friendly interface (e.g. menus) with a great deal of flexibility. – DrewAdams
It seems that (ps-print-buffer-with-faces) requires X11, so using it in --batch mode to pretty print multiple files results in no decoration (like (ps-print-buffer)). Here’s a way to print multiple files “with-faces” in unix shell:
<command that produces files you want to print, e.g. find> | xargs --max-args 1 -i emacs --file {} --no-desktop --eval '(ps-print-buffer-with-faces)' --eval '(kill-emacs)'And here’s a bash script to print two pages per sheet with no margin, 80 chars/line:
#!/bin/bash
if [[ $# != 1 ]]; then
echo "usage: $0 FILE" > /dev/stderr
exit 2
fi in="$1"
out="/tmp/$(basename "$in").ps"
emacs \
--quick \
--file "$in" \
--eval "
(let ((ps-top-margin 0)
;; adjust this and font size if enabling line numbers
(ps-left-margin 0)
(ps-right-margin 0)
(ps-inter-column 0)
(ps-landscape-mode t)
(ps-number-of-columns 2)
;; 80 chars per line
(ps-font-size 8.25)
;; (ps-line-number t)
(ps-line-number-font-size 10)
(ps-line-number-step 10)
(ps-print-color-p 'black-white))
(ps-print-buffer-with-faces \"$out\")
;; gives chars per line info, among other things
;; (ps-line-lengths)
;; (write-file \"/tmp/line-lengths.txt\")
(kill-emacs))
"
echo "$in -> $out"CategoryPrinting CategoryInternationalization, CategoryExternalUtilities, CategoryWThirtyTwo