aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa1999-10-20 01:06:27 +0000
committerKenichi Handa1999-10-20 01:06:27 +0000
commitbc0d41bdf09ca5759bd9c7b52781ae6e0c7ef8a2 (patch)
tree9a66fb0c46607c534d23fb48c0d51880b2bbedbd
parent4234d3d05607e30fc34f423d3b01807b213897ba (diff)
downloademacs-bc0d41bdf09ca5759bd9c7b52781ae6e0c7ef8a2.tar.gz
emacs-bc0d41bdf09ca5759bd9c7b52781ae6e0c7ef8a2.zip
Doc fix, duplex and setpagedevice configuration.
(ps-print-version): New version number (4.2). (ps-spool-config, ps-spool-tumble): New vars. (ps-print-prologue-1): Changed to defconst, adjust PostScript programming, new PostScript procedure to handle errors. (ps-print-prologue-2): Changed to defconst. (ps-print-duplex-feature): New const: duplex and tumble setting. (ps-setup, ps-begin-file): Fix funs. (ps-boolean-capitalized): New fun. Doc fix, n-up printing. (ps-print-version): New version number (5.0). (ps-page-dimensions-database): Added document media. (ps-n-up-printing, ps-n-up-margin, ps-n-up-border-p, ps-n-up-filling) (ps-page-order, ps-printing-region-p): New vars. (ps-n-up-printing, ps-n-up-filling, ps-header-sheet, ps-end-job): New funs. (ps-page-dimensions-get-media, ps-n-up-landscape, ps-n-up-lines) (ps-n-up-columns, ps-n-up-missing, ps-n-up-xcolumn, ps-n-up-ycolumn) (ps-n-up-xline, ps-n-up-yline, ps-n-up-repeat, ps-n-up-end) (ps-n-up-xstart, ps-n-up-ystart): New macros. (ps-print-begin-sheet-hook): New hook. (ps-boundingbox-re, ps-n-up-database, ps-n-up-filling-database): New const. (ps-setup, ps-begin-file, ps-get-buffer-name, ps-begin-job) (ps-end-file, ps-dummy-page, ps-generate): Fix funs. (ps-print-prologue-1): Adjust PostScript programming for n-up printing. (ps-count-lines): Changed to defun. (ps-header-page): Changed to defsubst, fix fun. (ps-printing-region): Doc fix, adjust programming code. (ps-output-boolean, ps-background-pages, ps-background-text) (ps-background-image, ps-background, ps-get-boundingbox): Adjust programming code. Doc fix, better customization. (ps-print-region-function, ps-number-of-columns, ps-spool-tumble) (ps-print-color-p, ps-printing-region-p, ps-n-up-database) (ps-end-file): Doc fix. (ps-setup, ps-begin-file): Fun fix. (postscript): New group. (ps-zebra-gray, ps-banner-page-when-duplexing): New vars. (ps-print-prologue-1): Adjust PostScript programming. (ps-print): Adjust group hierarchy. (ps-print-n-up, ps-print-zebra, ps-print-background, ps-print-printer) (ps-print-page): New subgroups. (ps-print-prologue-header, ps-printer-name, ps-lpr-command) (ps-lpr-switches, ps-page-dimensions-database, ps-paper-type) (ps-landscape-mode, ps-print-control-characters, ps-n-up-printing) (ps-n-up-margin, ps-n-up-border-p, ps-n-up-filling, ps-zebra-stripes) (ps-zebra-stripe-height, ps-print-background-image) (ps-print-background-text, ps-spool-config): Adjust customization. (dos-ps-printer): Definition eliminated.
-rw-r--r--lisp/ps-print.el1653
1 files changed, 1292 insertions, 361 deletions
diff --git a/lisp/ps-print.el b/lisp/ps-print.el
index 4e6f022b7aa..06739ee17c7 100644
--- a/lisp/ps-print.el
+++ b/lisp/ps-print.el
@@ -8,12 +8,12 @@
8;; Author: Kenichi Handa <handa@etl.go.jp> (multi-byte characters) 8;; Author: Kenichi Handa <handa@etl.go.jp> (multi-byte characters)
9;; Maintainer: Kenichi Handa <handa@etl.go.jp> (multi-byte characters) 9;; Maintainer: Kenichi Handa <handa@etl.go.jp> (multi-byte characters)
10;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br> 10;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br>
11;; Keywords: print, PostScript 11;; Keywords: wp, print, PostScript
12;; Time-stamp: <99/02/19 11:47:32 vinicius> 12;; Time-stamp: <99/07/03 20:16:48 vinicius>
13;; Version: 4.1.4 13;; Version: 5.0
14 14
15(defconst ps-print-version "4.1.4" 15(defconst ps-print-version "5.0"
16 "ps-print.el, v 4.1.4 <99/02/19 vinicius> 16 "ps-print.el, v 5.0 <99/07/03 vinicius>
17 17
18Vinicius's last change version -- this file may have been edited as part of 18Vinicius's last change version -- this file may have been edited as part of
19Emacs without changes to the version number. When reporting bugs, 19Emacs without changes to the version number. When reporting bugs,
@@ -43,7 +43,7 @@ Please send all bug fixes and enhancements to
43 43
44;;; Commentary: 44;;; Commentary:
45 45
46;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 46;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
47;; 47;;
48;; About ps-print 48;; About ps-print
49;; -------------- 49;; --------------
@@ -181,7 +181,7 @@ Please send all bug fixes and enhancements to
181;; Make sure that they contain appropriate values for your system; 181;; Make sure that they contain appropriate values for your system;
182;; see the usage notes below and the documentation of these variables. 182;; see the usage notes below and the documentation of these variables.
183;; 183;;
184;; The variable `ps-printer-name' determine the name of a local printer for 184;; The variable `ps-printer-name' determines the name of a local printer for
185;; printing PostScript files. 185;; printing PostScript files.
186;; 186;;
187;; NOTE: `ps-lpr-command' and `ps-lpr-switches' take their initial values 187;; NOTE: `ps-lpr-command' and `ps-lpr-switches' take their initial values
@@ -192,6 +192,11 @@ Please send all bug fixes and enhancements to
192;; `ps-printer-name' takes its initial value from the variable 192;; `ps-printer-name' takes its initial value from the variable
193;; `printer-name'. 193;; `printer-name'.
194;; 194;;
195;; The variable `ps-print-region-function' specifies a function to print the
196;; region on a PostScript printer.
197;; See definition of `call-process-region' for calling conventions. The fourth
198;; and the sixth arguments are both nil.
199;;
195;; 200;;
196;; The Page Layout 201;; The Page Layout
197;; --------------- 202;; ---------------
@@ -366,9 +371,9 @@ Please send all bug fixes and enhancements to
366;; It is possible to add PostScript prologue header comments besides that 371;; It is possible to add PostScript prologue header comments besides that
367;; ps-print generates by setting the variable `ps-print-prologue-header'. 372;; ps-print generates by setting the variable `ps-print-prologue-header'.
368;; 373;;
369;; `ps-print-prologue-header' may be a string or a symbol function which 374;; `ps-print-prologue-header' may be a string or a symbol function which returns
370;; returns a string. Note that this string is inserted on PostScript prologue 375;; a string. Note that this string is inserted on PostScript prologue header
371;; header section which is used to define some document characteristic through 376;; section which is used to define some document characteristic through
372;; PostScript special comments, like "%%Requirements: jog\n". 377;; PostScript special comments, like "%%Requirements: jog\n".
373;; 378;;
374;; By default `ps-print-prologue-header' is nil. 379;; By default `ps-print-prologue-header' is nil.
@@ -394,12 +399,96 @@ Please send all bug fixes and enhancements to
394;; Duplex Printers 399;; Duplex Printers
395;; --------------- 400;; ---------------
396;; 401;;
397;; If you have a duplex-capable printer (one that prints both sides of 402;; If you have a duplex-capable printer (one that prints both sides of the
398;; the paper), set `ps-spool-duplex' to t. 403;; paper), set `ps-spool-duplex' to t.
399;; ps-print will insert blank pages to make sure each buffer starts 404;; ps-print will insert blank pages to make sure each buffer starts on the
400;; on the correct side of the paper. 405;; correct side of the paper.
401;; Don't forget to set `ps-lpr-switches' to select duplex printing 406;;
402;; for your printer. 407;; The variable `ps-spool-config' specifies who is the responsable for setting
408;; duplex and page size switches. Valid values are:
409;;
410;; lpr-switches duplex and page size are configured by `ps-lpr-switches'.
411;; Don't forget to set `ps-lpr-switches' to select duplex
412;; printing for your printer.
413;;
414;; setpagedevice duplex and page size are configured by ps-print using the
415;; setpagedevice PostScript operator.
416;;
417;; nil duplex and page size are configured by ps-print *not* using
418;; the setpagedevice PostScript operator.
419;;
420;; Any other value is treated as nil.
421;;
422;; The default value is `lpr-switches'.
423;;
424;; WARNING: The setpagedevice PostScript operator affects ghostview utility when
425;; viewing file generated using landscape. Also on some printers,
426;; setpagedevice affects zebra stripes; on other printers,
427;; setpagedevice affects the left margin.
428;; Besides all that, if your printer does not have the paper size
429;; specified by setpagedevice, your printing will be aborted.
430;; So, if you need to use setpagedevice, set `ps-spool-config' to
431;; `setpagedevice', generate a test file and send it to your printer;
432;; if the printed file isn't ok, set `ps-spool-config' to nil.
433;;
434;; The variable `ps-spool-tumble' specifies how the page images on opposite
435;; sides of a sheet are oriented with respect to each other. If
436;; `ps-spool-tumble' is nil, produces output suitable for binding on the left or
437;; right. If `ps-spool-tumble' is non-nil, produces output suitable for binding
438;; at the top or bottom. It has effect only when `ps-spool-duplex' is non-nil.
439;; The default value is nil.
440;;
441;; Some printer system prints a header page and forces the first page be printed
442;; on header page back, when using duplex. If your printer system has this
443;; behavior, set variable `ps-banner-page-when-duplexing' to t.
444;;
445;; When `ps-banner-page-when-duplexing' is non-nil means the very first page is
446;; skipped. It's like the very first character of buffer (or region) is ^L
447;; (\014).
448;;
449;; The default for `ps-banner-page-when-duplexing' is nil (*don't* skip the very
450;; first page).
451;;
452;;
453;; N-up Printing
454;; -------------
455;;
456;; The variable `ps-n-up-printing' specifies the number of pages per sheet of
457;; paper. The value specified must be between 1 and 100. The default is 1.
458;;
459;; NOTE: some PostScript printer may crash printing if `ps-n-up-printing' is set
460;; to a high value (for example, 23). If this happens, set a lower value.
461;;
462;; The variable `ps-n-up-margin' specifies the margin in points between the
463;; sheet border and the n-up printing. The default is 1 cm (or 0.3937 inches,
464;; or 28.35 points).
465;;
466;; If variable `ps-n-up-border-p' is non-nil a border is drawn around each page.
467;; The default is t.
468;;
469;; The variable `ps-n-up-filling' specifies how page matrix is filled on each
470;; sheet of paper. Following are the valid values for `ps-n-up-filling' with a
471;; filling example using a 3x4 page matrix:
472;;
473;; left-top 1 2 3 4 left-bottom 9 10 11 12
474;; 5 6 7 8 5 6 7 8
475;; 9 10 11 12 1 2 3 4
476;;
477;; right-top 4 3 2 1 right-bottom 12 11 10 9
478;; 8 7 6 5 8 7 6 5
479;; 12 11 10 9 4 3 2 1
480;;
481;; top-left 1 4 7 10 bottom-left 3 6 9 12
482;; 2 5 8 11 2 5 8 11
483;; 3 6 9 12 1 4 7 10
484;;
485;; top-right 10 7 4 1 bottom-right 12 9 6 3
486;; 11 8 5 2 11 8 5 2
487;; 12 9 6 3 10 7 4 1
488;;
489;; Any other value is treated as left-top.
490;;
491;; The default value is left-top.
403;; 492;;
404;; 493;;
405;; Control And 8-bit Characters 494;; Control And 8-bit Characters
@@ -440,6 +529,8 @@ Please send all bug fixes and enhancements to
440;; 529;;
441;; See ps-mule.el for documentation. 530;; See ps-mule.el for documentation.
442;; 531;;
532;; See ps-print-def.el for definition.
533;;
443;; 534;;
444;; Line Number 535;; Line Number
445;; ----------- 536;; -----------
@@ -474,6 +565,10 @@ Please send all bug fixes and enhancements to
474;; The variable `ps-zebra-stripes' controls whether to print zebra stripes. 565;; The variable `ps-zebra-stripes' controls whether to print zebra stripes.
475;; Non-nil means yes, nil means no. The default is nil. 566;; Non-nil means yes, nil means no. The default is nil.
476;; 567;;
568;; The variable `ps-zebra-gray' controls the zebra stripes gray scale.
569;; It should be a float number between 0.0 (black color) and 1.0 (white color).
570;; The default is 0.95.
571;;
477;; See also section How Ps-Print Has A Text And/Or Image On Background. 572;; See also section How Ps-Print Has A Text And/Or Image On Background.
478;; 573;;
479;; 574;;
@@ -487,15 +582,19 @@ Please send all bug fixes and enhancements to
487;; place to initialize ps-print global data. 582;; place to initialize ps-print global data.
488;; For an example, see section Adding a New Font Family. 583;; For an example, see section Adding a New Font Family.
489;; 584;;
585;; `ps-print-begin-sheet-hook'
586;; It is evaluated on each beginning of sheet of paper.
587;; If `ps-n-up-printing' is equal to 1, `ps-print-begin-page-hook' is never
588;; evaluated.
589;;
490;; `ps-print-begin-page-hook' 590;; `ps-print-begin-page-hook'
491;; It is evaluated on each real beginning of page, that is, ps-print 591;; It is evaluated on each beginning of page, except in the beginning
492;; considers each beginning of column as a beginning of page, and a real 592;; of page that `ps-print-begin-sheet-hook' is evaluated.
493;; beginning of page is when the beginning of column coincides with a
494;; paper change on your printer.
495;; 593;;
496;; `ps-print-begin-column-hook' 594;; `ps-print-begin-column-hook'
497;; It is evaluated on each beginning of column, except in the beginning 595;; It is evaluated on each beginning of column, except in the beginning
498;; of column that `ps-print-begin-page-hook' is evaluated. 596;; of column that `ps-print-begin-page-hook' is evaluated or that
597;; `ps-print-begin-sheet-hook' is evaluated.
499;; 598;;
500;; 599;;
501;; Font Managing 600;; Font Managing
@@ -576,7 +675,9 @@ Please send all bug fixes and enhancements to
576;; (setq ps-font-info-database '(<your stuff> <the standard stuff>)) 675;; (setq ps-font-info-database '(<your stuff> <the standard stuff>))
577;; or, use `ps-print-hook' (see section Hooks): 676;; or, use `ps-print-hook' (see section Hooks):
578;; (add-hook 'ps-print-hook 677;; (add-hook 'ps-print-hook
579;; '(lambda () (setq ps-font-info-database (append ...)))) 678;; '(lambda ()
679;; (or (assq 'Helvetica ps-font-info-database)
680;; (setq ps-font-info-database (append ...)))))
580;; 681;;
581;; You can create new `mixed' font families like: 682;; You can create new `mixed' font families like:
582;; (my-mixed-family 683;; (my-mixed-family
@@ -688,8 +789,8 @@ Please send all bug fixes and enhancements to
688;; 789;;
689;; See the documentation for `ps-extend-face'. 790;; See the documentation for `ps-extend-face'.
690;; 791;;
691;; Let's, for example, remap font-lock-keyword-face to another foreground color 792;; Let's, for example, remap `font-lock-keyword-face' to another foreground
692;; and bold attribute: 793;; color and bold attribute:
693;; 794;;
694;; (ps-extend-face '(font-lock-keyword-face "RoyalBlue" nil bold) 'MERGE) 795;; (ps-extend-face '(font-lock-keyword-face "RoyalBlue" nil bold) 'MERGE)
695;; 796;;
@@ -789,6 +890,24 @@ Please send all bug fixes and enhancements to
789;; New since version 2.8 890;; New since version 2.8
790;; --------------------- 891;; ---------------------
791;; 892;;
893;; [vinicius] 990703 Vinicius Jose Latorre <vinicius@cpqd.com.br>
894;;
895;; Better customization.
896;; `ps-banner-page-when-duplexing' and `ps-zebra-gray'.
897;;
898;; [vinicius] 990513 Vinicius Jose Latorre <vinicius@cpqd.com.br>
899;;
900;; N-up printing.
901;; Hook: `ps-print-begin-sheet-hook'.
902;;
903;; [keinichi] 990509 Kein'ichi Handa <handa@etl.go.jp>
904;;
905;; `ps-print-region-function'
906;;
907;; [vinicius] 990301 Vinicius Jose Latorre <vinicius@cpqd.com.br>
908;;
909;; PostScript tumble and setpagedevice.
910;;
792;; [vinicius] 980922 Vinicius Jose Latorre <vinicius@cpqd.com.br> 911;; [vinicius] 980922 Vinicius Jose Latorre <vinicius@cpqd.com.br>
793;; 912;;
794;; PostScript prologue header comment insertion. 913;; PostScript prologue header comment insertion.
@@ -864,7 +983,6 @@ Please send all bug fixes and enhancements to
864;; Things to change 983;; Things to change
865;; ---------------- 984;; ----------------
866;; 985;;
867;; 2-up and 4-up capabilities.
868;; Avoid page break inside a paragraph. 986;; Avoid page break inside a paragraph.
869;; Add `ps-non-bold-faces' and `ps-non-italic-faces' (should be easy). 987;; Add `ps-non-bold-faces' and `ps-non-italic-faces' (should be easy).
870;; Improve the memory management for big files (hard?). 988;; Improve the memory management for big files (hard?).
@@ -931,7 +1049,7 @@ Please send all bug fixes and enhancements to
931;; interest. 1049;; interest.
932;; 1050;;
933;; Jim 1051;; Jim
934;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1052;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
935 1053
936;;; Code: 1054;;; Code:
937 1055
@@ -940,7 +1058,8 @@ Please send all bug fixes and enhancements to
940 1058
941;; For Emacs 20.2 and the earlier version. 1059;; For Emacs 20.2 and the earlier version.
942(eval-and-compile 1060(eval-and-compile
943 (and (string< mule-version "4.0") 1061 (and (boundp 'mule-version) ; only if mule package is loaded
1062 (string< mule-version "4.0")
944 (progn 1063 (progn
945 (defun set-buffer-multibyte (arg) 1064 (defun set-buffer-multibyte (arg)
946 (setq enable-multibyte-characters arg)) 1065 (setq enable-multibyte-characters arg))
@@ -954,10 +1073,16 @@ Please send all bug fixes and enhancements to
954 1073
955;;; Interface to the command system 1074;;; Interface to the command system
956 1075
1076(defgroup postscript nil
1077 "PostScript Group"
1078 :tag "PostScript"
1079 :group 'emacs)
1080
957(defgroup ps-print nil 1081(defgroup ps-print nil
958 "PostScript generator for Emacs 19" 1082 "PostScript generator for Emacs 19"
959 :prefix "ps-" 1083 :prefix "ps-"
960 :group 'wp) 1084 :group 'wp
1085 :group 'postscript)
961 1086
962(defgroup ps-print-horizontal nil 1087(defgroup ps-print-horizontal nil
963 "Horizontal page layout" 1088 "Horizontal page layout"
@@ -996,6 +1121,39 @@ Please send all bug fixes and enhancements to
996 :group 'ps-print 1121 :group 'ps-print
997 :group 'faces) 1122 :group 'faces)
998 1123
1124(defgroup ps-print-n-up nil
1125 "N-up customization"
1126 :prefix "ps-"
1127 :tag "N-Up"
1128 :group 'ps-print)
1129
1130(defgroup ps-print-zebra nil
1131 "Zebra customization"
1132 :prefix "ps-"
1133 :tag "Zebra"
1134 :group 'ps-print)
1135
1136(defgroup ps-print-background nil
1137 "Background customization"
1138 :prefix "ps-"
1139 :tag "Background"
1140 :group 'ps-print)
1141
1142(defgroup ps-print-printer nil
1143 "Printer customization"
1144 :prefix "ps-"
1145 :tag "Printer"
1146 :group 'ps-print)
1147
1148(defgroup ps-print-page nil
1149 "Page customization"
1150 :prefix "ps-"
1151 :tag "Page"
1152 :group 'ps-print)
1153
1154
1155(require 'ps-print-def) ; Common definitions
1156
999 1157
1000(defcustom ps-print-prologue-header nil 1158(defcustom ps-print-prologue-header nil
1001 "*PostScript prologue header comments besides that ps-print generates. 1159 "*PostScript prologue header comments besides that ps-print generates.
@@ -1021,7 +1179,8 @@ For more information about PostScript document comments, see:
1021 PostScript Language Reference Manual (2nd edition) 1179 PostScript Language Reference Manual (2nd edition)
1022 Adobe Systems Incorporated 1180 Adobe Systems Incorporated
1023 Appendix G: Document Structuring Conventions -- Version 3.0" 1181 Appendix G: Document Structuring Conventions -- Version 3.0"
1024 :type '(choice string symbol (other :tag "nil" nil)) 1182 :type '(choice :tag "Prologue Header"
1183 string symbol (other :tag "nil" nil))
1025 :group 'ps-print) 1184 :group 'ps-print)
1026 1185
1027(defcustom ps-printer-name (and (boundp 'printer-name) 1186(defcustom ps-printer-name (and (boundp 'printer-name)
@@ -1043,9 +1202,9 @@ appended to that file. \(Note that `ps-print' package already has
1043facilities for printing to a file, so you might as well use them instead 1202facilities for printing to a file, so you might as well use them instead
1044of changing the setting of this variable.\) If you want to silently 1203of changing the setting of this variable.\) If you want to silently
1045discard the printed output, set this to \"NUL\"." 1204discard the printed output, set this to \"NUL\"."
1046 :type '(choice (file :tag "Name") 1205 :type '(choice :tag "Printer Name"
1047 (const :tag "Default" nil)) 1206 file (other :tag "Pipe to ps-lpr-command" pipe))
1048 :group 'ps-print) 1207 :group 'ps-print-printer)
1049 1208
1050(defcustom ps-lpr-command lpr-command 1209(defcustom ps-lpr-command lpr-command
1051 "*Name of program for printing a PostScript file. 1210 "*Name of program for printing a PostScript file.
@@ -1058,18 +1217,19 @@ NT and Novell Netware respectively) are handled specially, using
1058treated like `lpr' except that an explicit filename is given as the last 1217treated like `lpr' except that an explicit filename is given as the last
1059argument." 1218argument."
1060 :type 'string 1219 :type 'string
1061 :group 'ps-print) 1220 :group 'ps-print-printer)
1062 1221
1063(defcustom ps-lpr-switches lpr-switches 1222(defcustom ps-lpr-switches lpr-switches
1064 "*A list of extra switches to pass to `ps-lpr-command'." 1223 "*A list of extra switches to pass to `ps-lpr-command'."
1065 :type '(repeat string) 1224 :type '(repeat string)
1066 :group 'ps-print) 1225 :group 'ps-print-printer)
1067 1226
1068(defcustom ps-print-region-function nil 1227(defcustom ps-print-region-function nil
1069 "Function to call to print the region on a PostScript printer. 1228 "*Specify a function to print the region on a PostScript printer.
1070See definition of `ps-do-despool' for calling conventions." 1229See definition of `call-process-region' for calling conventions. The fourth and
1230the sixth arguments are both nil."
1071 :type 'function 1231 :type 'function
1072 :group 'ps-print) 1232 :group 'ps-print-printer)
1073 1233
1074;;; Page layout 1234;;; Page layout
1075 1235
@@ -1092,29 +1252,30 @@ See definition of `ps-do-despool' for calling conventions."
1092;; B5 7.16 inch x 10.125 inch 1252;; B5 7.16 inch x 10.125 inch
1093 1253
1094(defcustom ps-page-dimensions-database 1254(defcustom ps-page-dimensions-database
1095 (list (list 'a4 (/ (* 72 21.0) 2.54) (/ (* 72 29.7) 2.54)) 1255 (list (list 'a4 (/ (* 72 21.0) 2.54) (/ (* 72 29.7) 2.54) "A4")
1096 (list 'a3 (/ (* 72 29.7) 2.54) (/ (* 72 42.0) 2.54)) 1256 (list 'a3 (/ (* 72 29.7) 2.54) (/ (* 72 42.0) 2.54) "A3")
1097 (list 'letter (* 72 8.5) (* 72 11.0)) 1257 (list 'letter (* 72 8.5) (* 72 11.0) "Letter")
1098 (list 'legal (* 72 8.5) (* 72 14.0)) 1258 (list 'legal (* 72 8.5) (* 72 14.0) "Legal")
1099 (list 'letter-small (* 72 7.68) (* 72 10.16)) 1259 (list 'letter-small (* 72 7.68) (* 72 10.16) "LetterSmall")
1100 (list 'tabloid (* 72 11.0) (* 72 17.0)) 1260 (list 'tabloid (* 72 11.0) (* 72 17.0) "Tabloid")
1101 (list 'ledger (* 72 17.0) (* 72 11.0)) 1261 (list 'ledger (* 72 17.0) (* 72 11.0) "Ledger")
1102 (list 'statement (* 72 5.5) (* 72 8.5)) 1262 (list 'statement (* 72 5.5) (* 72 8.5) "Statement")
1103 (list 'executive (* 72 7.5) (* 72 10.0)) 1263 (list 'executive (* 72 7.5) (* 72 10.0) "Executive")
1104 (list 'a4small (* 72 7.47) (* 72 10.85)) 1264 (list 'a4small (* 72 7.47) (* 72 10.85) "A4Small")
1105 (list 'b4 (* 72 10.125) (* 72 14.33)) 1265 (list 'b4 (* 72 10.125) (* 72 14.33) "B4")
1106 (list 'b5 (* 72 7.16) (* 72 10.125))) 1266 (list 'b5 (* 72 7.16) (* 72 10.125) "B5"))
1107 "*List associating a symbolic paper type to its width and height. 1267 "*List associating a symbolic paper type to its width, height and doc media.
1108see `ps-paper-type'." 1268See `ps-paper-type'."
1109 :type '(repeat (list :tag "Paper Type" 1269 :type '(repeat (list :tag "Paper Type"
1110 (symbol :tag "Name") 1270 (symbol :tag "Name")
1111 (number :tag "Width") 1271 (number :tag "Width")
1112 (number :tag "Height"))) 1272 (number :tag "Height")
1113 :group 'ps-print) 1273 (string :tag "Media")))
1274 :group 'ps-print-page)
1114 1275
1115;;;###autoload 1276;;;###autoload
1116(defcustom ps-paper-type 'letter 1277(defcustom ps-paper-type 'letter
1117 "*Specifies the size of paper to format for. 1278 "*Specify the size of paper to format for.
1118Should be one of the paper types defined in `ps-page-dimensions-database', for 1279Should be one of the paper types defined in `ps-page-dimensions-database', for
1119example `letter', `legal' or `a4'." 1280example `letter', `legal' or `a4'."
1120 :type '(symbol :validate (lambda (wid) 1281 :type '(symbol :validate (lambda (wid)
@@ -1123,16 +1284,16 @@ example `letter', `legal' or `a4'."
1123 nil 1284 nil
1124 (widget-put wid :error "Unknown paper size") 1285 (widget-put wid :error "Unknown paper size")
1125 wid))) 1286 wid)))
1126 :group 'ps-print) 1287 :group 'ps-print-page)
1127 1288
1128(defcustom ps-landscape-mode nil 1289(defcustom ps-landscape-mode nil
1129 "*Non-nil means print in landscape mode." 1290 "*Non-nil means print in landscape mode."
1130 :type 'boolean 1291 :type 'boolean
1131 :group 'ps-print) 1292 :group 'ps-print-page)
1132 1293
1133(defcustom ps-print-control-characters 'control-8-bit 1294(defcustom ps-print-control-characters 'control-8-bit
1134 "*Specifies the printable form for control and 8-bit characters. 1295 "*Specify the printable form for control and 8-bit characters.
1135That is, instead of sending, for example, a ^D (\004) to printer, 1296That is, instead of sending, for example, a ^D (\\004) to printer,
1136it is sent the string \"^D\". 1297it is sent the string \"^D\".
1137 1298
1138Valid values are: 1299Valid values are:
@@ -1155,26 +1316,88 @@ Valid values are:
1155 current font. 1316 current font.
1156 1317
1157Any other value is treated as nil." 1318Any other value is treated as nil."
1158 :type '(choice (const 8-bit) (const control-8-bit) 1319 :type '(choice :tag "Control Char"
1320 (const 8-bit) (const control-8-bit)
1159 (const control) (other :tag "nil" nil)) 1321 (const control) (other :tag "nil" nil))
1160 :group 'ps-print) 1322 :group 'ps-print)
1161 1323
1324(defcustom ps-n-up-printing 1
1325 "*Specify the number of pages per sheet paper."
1326 :type '(integer
1327 :tag "N Up Printing"
1328 :validate
1329 (lambda (wid)
1330 (if (and (< 0 (widget-value wid))
1331 (<= (widget-value wid) 100))
1332 nil
1333 (widget-put
1334 wid :error
1335 "Number of pages per sheet paper must be between 1 and 100.")
1336 wid)))
1337 :group 'ps-print-n-up)
1338
1339(defcustom ps-n-up-margin (/ (* 72 1.0) 2.54) ; 1 cm
1340 "*Specify the margin in points between the sheet border and n-up printing."
1341 :type 'number
1342 :group 'ps-print-n-up)
1343
1344(defcustom ps-n-up-border-p t
1345 "*Non-nil means a border is drawn around each page."
1346 :type 'boolean
1347 :group 'ps-print-n-up)
1348
1349(defcustom ps-n-up-filling 'left-top
1350 "*Specify how page matrix is filled on each sheet of paper.
1351
1352Following are the valid values for `ps-n-up-filling' with a filling example
1353using a 3x4 page matrix:
1354
1355 `left-top' 1 2 3 4 `left-bottom' 9 10 11 12
1356 5 6 7 8 5 6 7 8
1357 9 10 11 12 1 2 3 4
1358
1359 `right-top' 4 3 2 1 `right-bottom' 12 11 10 9
1360 8 7 6 5 8 7 6 5
1361 12 11 10 9 4 3 2 1
1362
1363 `top-left' 1 4 7 10 `bottom-left' 3 6 9 12
1364 2 5 8 11 2 5 8 11
1365 3 6 9 12 1 4 7 10
1366
1367 `top-right' 10 7 4 1 `bottom-right' 12 9 6 3
1368 11 8 5 2 11 8 5 2
1369 12 9 6 3 10 7 4 1
1370
1371Any other value is treated as `left-top'."
1372 :type '(choice :tag "N-Up Filling"
1373 (const left-top) (const left-bottom)
1374 (const right-top) (const right-bottom)
1375 (const top-left) (const bottom-left)
1376 (const top-right) (const bottom-right))
1377 :group 'ps-print-n-up)
1378
1162(defcustom ps-number-of-columns (if ps-landscape-mode 2 1) 1379(defcustom ps-number-of-columns (if ps-landscape-mode 2 1)
1163 "*Specifies the number of columns" 1380 "*Specify the number of columns"
1164 :type 'number 1381 :type 'number
1165 :group 'ps-print) 1382 :group 'ps-print)
1166 1383
1167(defcustom ps-zebra-stripes nil 1384(defcustom ps-zebra-stripes nil
1168 "*Non-nil means print zebra stripes. 1385 "*Non-nil means print zebra stripes.
1169See also documentation for `ps-zebra-stripe-height'." 1386See also documentation for `ps-zebra-stripe-height' and `ps-zebra-gray'."
1170 :type 'boolean 1387 :type 'boolean
1171 :group 'ps-print) 1388 :group 'ps-print-zebra)
1172 1389
1173(defcustom ps-zebra-stripe-height 3 1390(defcustom ps-zebra-stripe-height 3
1174 "*Number of zebra stripe lines. 1391 "*Number of zebra stripe lines.
1175See also documentation for `ps-zebra-stripes'." 1392See also documentation for `ps-zebra-stripes' and `ps-zebra-gray'."
1176 :type 'number 1393 :type 'number
1177 :group 'ps-print) 1394 :group 'ps-print-zebra)
1395
1396(defcustom ps-zebra-gray 0.95
1397 "*Zebra stripe gray scale.
1398See also documentation for `ps-zebra-stripes' and `ps-zebra-stripe-height'."
1399 :type 'number
1400 :group 'ps-print-zebra)
1178 1401
1179(defcustom ps-line-number nil 1402(defcustom ps-line-number nil
1180 "*Non-nil means print line number." 1403 "*Non-nil means print line number."
@@ -1212,18 +1435,18 @@ PostScript programming that returns a float or integer value.
1212For example, if you wish to print an EPS image on all pages do: 1435For example, if you wish to print an EPS image on all pages do:
1213 1436
1214 '((\"~/images/EPS-image.ps\"))" 1437 '((\"~/images/EPS-image.ps\"))"
1215 :type '(repeat (list file 1438 :type '(repeat (list (file :tag "EPS File")
1216 (choice :tag "X" number string (const nil)) 1439 (choice :tag "X" number string (const nil))
1217 (choice :tag "Y" number string (const nil)) 1440 (choice :tag "Y" number string (const nil))
1218 (choice :tag "X Scale" number string (const nil)) 1441 (choice :tag "X Scale" number string (const nil))
1219 (choice :tag "Y Scale" number string (const nil)) 1442 (choice :tag "Y Scale" number string (const nil))
1220 (choice :tag "Rotation" number string (const nil)) 1443 (choice :tag "Rotation" number string (const nil))
1221 (repeat :tag "Pages" :inline t 1444 (repeat :tag "Pages" :inline t
1222 (radio integer 1445 (radio (integer :tag "Page")
1223 (cons :tag "Range" 1446 (cons :tag "Range"
1224 (integer :tag "From") 1447 (integer :tag "From")
1225 (integer :tag "To")))))) 1448 (integer :tag "To"))))))
1226 :group 'ps-print) 1449 :group 'ps-print-background)
1227 1450
1228(defcustom ps-print-background-text nil 1451(defcustom ps-print-background-text nil
1229 "*Text list to be printed on background. 1452 "*Text list to be printed on background.
@@ -1260,7 +1483,7 @@ PostScript programming that returns a float or integer value.
1260For example, if you wish to print text \"Preliminary\" on all pages do: 1483For example, if you wish to print text \"Preliminary\" on all pages do:
1261 1484
1262 '((\"Preliminary\"))" 1485 '((\"Preliminary\"))"
1263 :type '(repeat (list string 1486 :type '(repeat (list (string :tag "Text")
1264 (choice :tag "X" number string (const nil)) 1487 (choice :tag "X" number string (const nil))
1265 (choice :tag "Y" number string (const nil)) 1488 (choice :tag "Y" number string (const nil))
1266 (choice :tag "Font" string (const nil)) 1489 (choice :tag "Font" string (const nil))
@@ -1268,11 +1491,11 @@ For example, if you wish to print text \"Preliminary\" on all pages do:
1268 (choice :tag "Gray" number string (const nil)) 1491 (choice :tag "Gray" number string (const nil))
1269 (choice :tag "Rotation" number string (const nil)) 1492 (choice :tag "Rotation" number string (const nil))
1270 (repeat :tag "Pages" :inline t 1493 (repeat :tag "Pages" :inline t
1271 (radio integer 1494 (radio (integer :tag "Page")
1272 (cons :tag "Range" 1495 (cons :tag "Range"
1273 (integer :tag "From") 1496 (integer :tag "From")
1274 (integer :tag "To")))))) 1497 (integer :tag "To"))))))
1275 :group 'ps-print) 1498 :group 'ps-print-background)
1276 1499
1277;;; Horizontal layout 1500;;; Horizontal layout
1278 1501
@@ -1369,14 +1592,55 @@ NOTE: page numbers are displayed as part of headers,
1369 :type 'boolean 1592 :type 'boolean
1370 :group 'ps-print-header) 1593 :group 'ps-print-header)
1371 1594
1372(defcustom ps-spool-duplex nil ; Not many people have duplex 1595(defcustom ps-spool-config 'lpr-switches
1373 ; printers, so default to nil. 1596 "*Specify who is responsable for setting duplex and page size switches.
1374 "*Non-nil indicates spooling is for a two-sided printer. 1597
1375For a duplex printer, the `ps-spool-*' commands will insert blank pages 1598Valid values are:
1376as needed between print jobs so that the next buffer printed will 1599
1377start on the right page. Also, if headers are turned on, the headers 1600 `lpr-switches' duplex and page size are configured by `ps-lpr-switches'.
1378will be reversed on duplex printers so that the page numbers fall to 1601 Don't forget to set `ps-lpr-switches' to select duplex
1379the left on even-numbered pages." 1602 printing for your printer.
1603
1604 `setpagedevice' duplex and page size are configured by ps-print using the
1605 setpagedevice PostScript operator.
1606
1607 nil duplex and page size are configured by ps-print *not* using
1608 the setpagedevice PostScript operator.
1609
1610Any other value is treated as nil.
1611
1612WARNING: The setpagedevice PostScript operator affects ghostview utility when
1613 viewing file generated using landscape. Also on some printers,
1614 setpagedevice affects zebra stripes; on other printers, setpagedevice
1615 affects the left margin.
1616 Besides all that, if your printer does not have the paper size
1617 specified by setpagedevice, your printing will be aborted.
1618 So, if you need to use setpagedevice, set `ps-spool-config' to
1619 `setpagedevice', generate a test file and send it to your printer; if
1620 the printed file isn't ok, set `ps-spool-config' to nil."
1621 :type '(choice :tag "Spool Config"
1622 (const lpr-switches) (const setpagedevice)
1623 (other :tag "nil" nil))
1624 :group 'ps-print-header)
1625
1626(defcustom ps-spool-duplex nil ; Not many people have duplex printers,
1627 ; so default to nil.
1628 "*Non-nil generates PostScript for a two-sided printer.
1629For a duplex printer, the `ps-spool-*' and `ps-print-*' commands will insert
1630blank pages as needed between print jobs so that the next buffer printed will
1631start on the right page. Also, if headers are turned on, the headers will be
1632reversed on duplex printers so that the page numbers fall to the left on
1633even-numbered pages."
1634 :type 'boolean
1635 :group 'ps-print-header)
1636
1637(defcustom ps-spool-tumble nil
1638 "*Specify how the page images on opposite sides of a sheet are oriented.
1639If `ps-spool-tumble' is nil, produces output suitable for binding on the left or
1640right. If `ps-spool-tumble' is non-nil, produces output suitable for binding at
1641the top or bottom.
1642
1643It has effect only when `ps-spool-duplex' is non-nil."
1380 :type 'boolean 1644 :type 'boolean
1381 :group 'ps-print-header) 1645 :group 'ps-print-header)
1382 1646
@@ -1563,7 +1827,7 @@ You can get all the fonts of YOUR printer using `ReportAllFontInfo'."
1563(defcustom ps-print-color-p (or (fboundp 'x-color-values) ; Emacs 1827(defcustom ps-print-color-p (or (fboundp 'x-color-values) ; Emacs
1564 (fboundp 'color-instance-rgb-components)) 1828 (fboundp 'color-instance-rgb-components))
1565 ; XEmacs 1829 ; XEmacs
1566 "*If non-nil, print the buffer's text in color." 1830 "*Non-nil means print the buffer's text in color."
1567 :type 'boolean 1831 :type 'boolean
1568 :group 'ps-print-color) 1832 :group 'ps-print-color)
1569 1833
@@ -1686,6 +1950,12 @@ variable."
1686 :type 'boolean 1950 :type 'boolean
1687 :group 'ps-print-face) 1951 :group 'ps-print-face)
1688 1952
1953(defcustom ps-banner-page-when-duplexing nil
1954 "*Non-nil means the very first page is skipped.
1955It's like the very first character of buffer (or region) is ^L (\\014)."
1956 :type 'boolean
1957 :group 'ps-print-header)
1958
1689;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1959;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1690;; User commands 1960;; User commands
1691 1961
@@ -1817,10 +2087,11 @@ The table depends on the current ps-print setup."
1817 "Return the current PostScript-generation setup." 2087 "Return the current PostScript-generation setup."
1818 (format 2088 (format
1819 " 2089 "
1820\(setq ps-print-color-p %s 2090\(setq ps-print-color-p %s
1821 ps-lpr-command %S 2091 ps-lpr-command %S
1822 ps-lpr-switches %s 2092 ps-lpr-switches %s
1823 ps-printer-name %S 2093 ps-printer-name %S
2094 ps-print-region-function %s
1824 2095
1825 ps-paper-type %s 2096 ps-paper-type %s
1826 ps-landscape-mode %s 2097 ps-landscape-mode %s
@@ -1828,6 +2099,7 @@ The table depends on the current ps-print setup."
1828 2099
1829 ps-zebra-stripes %s 2100 ps-zebra-stripes %s
1830 ps-zebra-stripe-height %s 2101 ps-zebra-stripe-height %s
2102 ps-zebra-gray %s
1831 ps-line-number %s 2103 ps-line-number %s
1832 2104
1833 ps-print-control-characters %s 2105 ps-print-control-characters %s
@@ -1838,19 +2110,27 @@ The table depends on the current ps-print setup."
1838 2110
1839 ps-print-prologue-header %s 2111 ps-print-prologue-header %s
1840 2112
1841 ps-left-margin %s 2113 ps-left-margin %s
1842 ps-right-margin %s 2114 ps-right-margin %s
1843 ps-inter-column %s 2115 ps-inter-column %s
1844 ps-bottom-margin %s 2116 ps-bottom-margin %s
1845 ps-top-margin %s 2117 ps-top-margin %s
1846 ps-header-offset %s 2118 ps-header-offset %s
1847 ps-header-line-pad %s 2119 ps-header-line-pad %s
1848 ps-print-header %s 2120 ps-print-header %s
1849 ps-print-only-one-header %s 2121 ps-print-only-one-header %s
1850 ps-print-header-frame %s 2122 ps-print-header-frame %s
1851 ps-header-lines %s 2123 ps-header-lines %s
1852 ps-show-n-of-n %s 2124 ps-show-n-of-n %s
1853 ps-spool-duplex %s 2125 ps-spool-config %s
2126 ps-spool-duplex %s
2127 ps-spool-tumble %s
2128 ps-banner-page-when-duplexing %s
2129
2130 ps-n-up-printing %s
2131 ps-n-up-margin %s
2132 ps-n-up-border-p %s
2133 ps-n-up-filling %s
1854 2134
1855 ps-multibyte-buffer %s 2135 ps-multibyte-buffer %s
1856 ps-font-family %s 2136 ps-font-family %s
@@ -1863,11 +2143,13 @@ The table depends on the current ps-print setup."
1863 ps-lpr-command 2143 ps-lpr-command
1864 (ps-print-quote ps-lpr-switches) 2144 (ps-print-quote ps-lpr-switches)
1865 ps-printer-name 2145 ps-printer-name
2146 (ps-print-quote ps-print-region-function)
1866 (ps-print-quote ps-paper-type) 2147 (ps-print-quote ps-paper-type)
1867 ps-landscape-mode 2148 ps-landscape-mode
1868 ps-number-of-columns 2149 ps-number-of-columns
1869 ps-zebra-stripes 2150 ps-zebra-stripes
1870 ps-zebra-stripe-height 2151 ps-zebra-stripe-height
2152 ps-zebra-gray
1871 ps-line-number 2153 ps-line-number
1872 (ps-print-quote ps-print-control-characters) 2154 (ps-print-quote ps-print-control-characters)
1873 (ps-print-quote ps-print-background-image) 2155 (ps-print-quote ps-print-background-image)
@@ -1885,8 +2167,15 @@ The table depends on the current ps-print setup."
1885 ps-print-header-frame 2167 ps-print-header-frame
1886 ps-header-lines 2168 ps-header-lines
1887 ps-show-n-of-n 2169 ps-show-n-of-n
2170 (ps-print-quote ps-spool-config)
1888 ps-spool-duplex 2171 ps-spool-duplex
1889 (ps-print-quote ps-multibyte-buffer) ; see `ps-mule.el' 2172 ps-spool-tumble
2173 ps-banner-page-when-duplexing
2174 ps-n-up-printing
2175 ps-n-up-margin
2176 ps-n-up-border-p
2177 (ps-print-quote ps-n-up-filling)
2178 (ps-print-quote ps-multibyte-buffer) ; see `ps-mule.el' and `ps-print-def.el'
1890 (ps-print-quote ps-font-family) 2179 (ps-print-quote ps-font-family)
1891 (ps-print-quote ps-font-size) 2180 (ps-print-quote ps-font-size)
1892 (ps-print-quote ps-header-font-family) 2181 (ps-print-quote ps-header-font-family)
@@ -1936,8 +2225,9 @@ The table depends on the current ps-print setup."
1936 2225
1937(require 'time-stamp) 2226(require 'time-stamp)
1938 2227
1939(defvar ps-print-prologue-1 2228(defconst ps-print-prologue-1
1940 "% ISOLatin1Encoding stolen from ps_init.ps in GhostScript 2.6.1.4: 2229 "
2230% ISOLatin1Encoding stolen from ps_init.ps in GhostScript 2.6.1.4:
1941/ISOLatin1Encoding where { pop } { 2231/ISOLatin1Encoding where { pop } {
1942% -- The ISO Latin-1 encoding vector isn't known, so define it. 2232% -- The ISO Latin-1 encoding vector isn't known, so define it.
1943% -- The first half is the same as the standard encoding, 2233% -- The first half is the same as the standard encoding,
@@ -2263,7 +2553,7 @@ StandardEncoding 46 82 getinterval aload pop
2263% stack: -- 2553% stack: --
2264/printZebra { 2554/printZebra {
2265 gsave 2555 gsave
2266 0.985 setgray 2556 ZebraGray setgray
2267 /double-zebra ZebraHeight ZebraHeight add def 2557 /double-zebra ZebraHeight ZebraHeight add def
2268 /yiter double-zebra LineHeight mul neg def 2558 /yiter double-zebra LineHeight mul neg def
2269 /xiter PrintWidth InterColumn add def 2559 /xiter PrintWidth InterColumn add def
@@ -2327,22 +2617,50 @@ StandardEncoding 46 82 getinterval aload pop
2327 /SpaceWidth /f0 findfont setfont ( ) stringwidth pop def 2617 /SpaceWidth /f0 findfont setfont ( ) stringwidth pop def
2328 % ---- save the state of the document (useful for ghostscript!) 2618 % ---- save the state of the document (useful for ghostscript!)
2329 /docState save def 2619 /docState save def
2330 % ---- [jack] Kludge: my ghostscript window is 21x27.7 instead of 21x29.7
2331 /JackGhostscript where {pop 1 27.7 29.7 div scale}if
2332 % ---- [andrewi] set PageSize based on chosen dimensions 2620 % ---- [andrewi] set PageSize based on chosen dimensions
2333% /setpagedevice where { 2621 UseSetpagedevice {
2334% pop 2622 0
2335% 1 dict dup 2623 {<< /PageSize [PageWidth LandscapePageHeight] >> setpagedevice}
2336% /PageSize [ PrintPageWidth LeftMargin add RightMargin add 2624 CheckConfig
2337% LandscapePageHeight ] put 2625 }{
2338% setpagedevice
2339% }{
2340 LandscapeMode { 2626 LandscapeMode {
2341 % ---- translate to bottom-right corner of Portrait page 2627 % ---- translate to bottom-right corner of Portrait page
2342 LandscapePageHeight 0 translate 2628 LandscapePageHeight 0 translate
2343 90 rotate 2629 90 rotate
2344 }if 2630 }if
2345% }ifelse 2631 }ifelse
2632 % ---- [jack] Kludge: my ghostscript window is 21x27.7 instead of 21x29.7
2633 /JackGhostscript where {pop 1 27.7 29.7 div scale}if
2634 % ---- N-Up printing
2635 N-Up 1 gt {
2636 % ---- landscape
2637 N-Up-Landscape {
2638 PageWidth 0 translate
2639 90 rotate
2640 }if
2641 N-Up-Margin dup translate
2642 % ---- scale
2643 LandscapeMode{
2644 /HH PageWidth def
2645 /WW LandscapePageHeight def
2646 }{
2647 /HH LandscapePageHeight def
2648 /WW PageWidth def
2649 }ifelse
2650 WW N-Up-Margin sub N-Up-Margin sub
2651 N-Up-Landscape
2652 {N-Up-Lines div HH}{N-Up-Columns N-Up-Missing add div WW}ifelse
2653 div dup scale
2654 0 N-Up-Repeat 1 sub LandscapePageHeight mul translate
2655 % ---- go to start position in page matrix
2656 N-Up-XStart N-Up-Missing 0.5 mul
2657 LandscapeMode{
2658 LandscapePageHeight mul N-Up-YStart add
2659 }{
2660 PageWidth mul add N-Up-YStart
2661 }ifelse
2662 translate
2663 }if
2346 /ColumnWidth PrintWidth InterColumn add def 2664 /ColumnWidth PrintWidth InterColumn add def
2347 % ---- translate to lower left corner of TEXT 2665 % ---- translate to lower left corner of TEXT
2348 LeftMargin BottomMargin translate 2666 LeftMargin BottomMargin translate
@@ -2350,61 +2668,108 @@ StandardEncoding 46 82 getinterval aload pop
2350 /f0 F % this installs Ascent 2668 /f0 F % this installs Ascent
2351 /PrintStartY PrintHeight Ascent sub def 2669 /PrintStartY PrintHeight Ascent sub def
2352 /ColumnIndex 1 def 2670 /ColumnIndex 1 def
2353} def 2671 /N-Up-Counter N-Up-End 1 sub def
2672 SkipFirstPage{save showpage restore}if
2673}def
2354 2674
2355/EndDoc { 2675/EndDoc {
2356 % ---- on last page but not last column, spit out the page
2357 ColumnIndex 1 eq not { showpage } if
2358 % ---- restore the state of the document (useful for ghostscript!) 2676 % ---- restore the state of the document (useful for ghostscript!)
2359 docState restore 2677 docState restore
2360} def 2678}def
2361 2679
2362/BeginDSCPage { 2680/BeginDSCPage {
2363 % ---- when 1st column, save the state of the page 2681 % ---- when 1st column, save the state of the page
2364 ColumnIndex 1 eq { /pageState save def } if 2682 ColumnIndex 1 eq {
2683 /pageState save def
2684 }if
2365 % ---- save the state of the column 2685 % ---- save the state of the column
2366 /columnState save def 2686 /columnState save def
2367} def 2687}def
2368 2688
2369/PrintHeaderWidth PrintOnlyOneHeader{PrintPageWidth}{PrintWidth}ifelse def 2689/PrintHeaderWidth PrintOnlyOneHeader{PrintPageWidth}{PrintWidth}ifelse def
2370 2690
2371/BeginPage { 2691/BeginPage {
2372 % ---- when 1st column, print all background effects 2692 % ---- when 1st column, print all background effects
2373 ColumnIndex 1 eq { 2693 ColumnIndex 1 eq {
2374 0 PrintStartY moveto % move to where printing will start 2694 0 PrintStartY moveto % move to where printing will start
2375 Zebra {printZebra}if 2695 Zebra {printZebra}if
2376 printGlobalBackground 2696 printGlobalBackground
2377 printLocalBackground 2697 printLocalBackground
2378 } if 2698 }if
2379 PrintHeader { 2699 PrintHeader {
2380 PrintOnlyOneHeader{ColumnIndex 1 eq}{true}ifelse { 2700 PrintOnlyOneHeader{ColumnIndex 1 eq}{true}ifelse {
2381 PrintHeaderFrame {HeaderFrame}if 2701 PrintHeaderFrame {HeaderFrame}if
2382 HeaderText 2702 HeaderText
2383 } if 2703 }if
2384 } if 2704 }if
2385 0 PrintStartY moveto % move to where printing will start 2705 0 PrintStartY moveto % move to where printing will start
2386 PLN 2706 PLN
2387} def 2707}def
2388 2708
2389/EndPage { 2709/EndPage {
2390 bg { eolbg } if 2710 bg {eolbg}if
2391} def 2711}def
2392 2712
2393/EndDSCPage { 2713/EndDSCPage {
2394 ColumnIndex NumberOfColumns eq { 2714 ColumnIndex NumberOfColumns eq {
2395 % ---- on last column, spit out the page
2396 showpage
2397 % ---- restore the state of the page 2715 % ---- restore the state of the page
2398 pageState restore 2716 pageState restore
2399 /ColumnIndex 1 def 2717 /ColumnIndex 1 def
2400 } { % else 2718 % ---- N-up printing
2719 N-Up 1 gt {
2720 N-Up-Counter 0 gt {
2721 % ---- Next page on same row
2722 /N-Up-Counter N-Up-Counter 1 sub def
2723 N-Up-XColumn N-Up-YColumn
2724 }{
2725 % ---- Next page on next line
2726 /N-Up-Counter N-Up-End 1 sub def
2727 N-Up-XLine N-Up-YLine
2728 }ifelse
2729 translate
2730 }if
2731 }{ % else
2401 % ---- restore the state of the current column 2732 % ---- restore the state of the current column
2402 columnState restore 2733 columnState restore
2403 % ---- and translate to the next column 2734 % ---- and translate to the next column
2404 ColumnWidth 0 translate 2735 ColumnWidth 0 translate
2405 /ColumnIndex ColumnIndex 1 add def 2736 /ColumnIndex ColumnIndex 1 add def
2406 } ifelse 2737 }ifelse
2407} def 2738}def
2739
2740% stack: number-of-pages-per-sheet |- --
2741/BeginSheet {
2742 /sheetState save def
2743 /pages-per-sheet exch def
2744 % ---- N-up printing
2745 N-Up 1 gt N-Up-Border and pages-per-sheet 0 gt and {
2746 % ---- page border
2747 gsave
2748 0 setgray
2749 LeftMargin neg BottomMargin neg moveto
2750 N-Up-Repeat
2751 {N-Up-End
2752 {gsave
2753 PageWidth 0 rlineto
2754 0 LandscapePageHeight rlineto
2755 PageWidth neg 0 rlineto
2756 closepath stroke
2757 grestore
2758 /pages-per-sheet pages-per-sheet 1 sub def
2759 pages-per-sheet 0 le{exit}if
2760 N-Up-XColumn N-Up-YColumn rmoveto
2761 }repeat
2762 pages-per-sheet 0 le{exit}if
2763 N-Up-XLine N-Up-XColumn sub N-Up-YLine rmoveto
2764 }repeat
2765 grestore
2766 }if
2767}def
2768
2769/EndSheet {
2770 showpage
2771 sheetState restore
2772}def
2408 2773
2409/SetHeaderLines { % nb-lines -- 2774/SetHeaderLines { % nb-lines --
2410 /HeaderLines exch def 2775 /HeaderLines exch def
@@ -2485,8 +2850,8 @@ StandardEncoding 46 82 getinterval aload pop
2485 2850
2486 % ---- hack: `PN 1 and' == `PN 2 modulo' 2851 % ---- hack: `PN 1 and' == `PN 2 modulo'
2487 2852
2488 % ---- if duplex and even page number, then exchange left and right 2853 % ---- if even page number and duplex, then exchange left and right
2489 Duplex PageNumber 1 and 0 eq and { exch } if 2854 PageNumber 1 and 0 eq DuplexValue and { exch } if
2490 2855
2491 { % ---- process the left lines 2856 { % ---- process the left lines
2492 aload pop 2857 aload pop
@@ -2524,6 +2889,11 @@ StandardEncoding 46 82 getinterval aload pop
2524 /t1 12 /Helvetica-Oblique DefFont 2889 /t1 12 /Helvetica-Oblique DefFont
2525 /t1 F 2890 /t1 F
2526 gsave 2891 gsave
2892 (languagelevel = ) show
2893 gs_languagelevel 32 string cvs show
2894 grestore
2895 0 FontHeight neg rmoveto
2896 gsave
2527 (For ) show 2897 (For ) show
2528 128 string cvs show 2898 128 string cvs show
2529 ( ) show 2899 ( ) show
@@ -2557,9 +2927,29 @@ StandardEncoding 46 82 getinterval aload pop
2557% 3 cm 20 cm moveto 10 /Courier ReportFontInfo showpage 2927% 3 cm 20 cm moveto 10 /Courier ReportFontInfo showpage
2558% 3 cm 20 cm moveto ReportAllFontInfo showpage 2928% 3 cm 20 cm moveto ReportAllFontInfo showpage
2559 2929
2930/ErrorMessages
2931 [(This PostScript printer is not configured with this document page size.)
2932 (Duplex printing is not supported on this PostScript printer.)]def
2933
2934% stack: error-index proc |- --
2935/CheckConfig {
2936 stopped {
2937 1 cm LandscapePageHeight 0.5 mul moveto
2938 /Courier findfont 10 scalefont setfont
2939 gsave
2940 (ps-print error:) show
2941 grestore
2942 0 -10 rmoveto
2943 ErrorMessages exch get show
2944 showpage
2945 $error /newerror false put
2946 stop
2947 }if
2948} bind def
2949
2560") 2950")
2561 2951
2562(defvar ps-print-prologue-2 2952(defconst ps-print-prologue-2
2563 " 2953 "
2564% ---- These lines must be kept together because... 2954% ---- These lines must be kept together because...
2565 2955
@@ -2574,6 +2964,20 @@ StandardEncoding 46 82 getinterval aload pop
2574 2964
2575") 2965")
2576 2966
2967(defconst ps-print-duplex-feature
2968 "
2969% --- duplex feature verification
29701
2971UseSetpagedevice {
2972 {<< /Duplex DuplexValue /Tumble TumbleValue >> setpagedevice}
2973}{
2974 {statusdict begin
2975 DuplexValue setduplexmode TumbleValue settumble
2976 end}
2977}ifelse
2978CheckConfig
2979")
2980
2577;; Start Editing Here: 2981;; Start Editing Here:
2578 2982
2579(defvar ps-source-buffer nil) 2983(defvar ps-source-buffer nil)
@@ -2584,6 +2988,7 @@ StandardEncoding 46 82 getinterval aload pop
2584(defvar ps-output-tail nil) 2988(defvar ps-output-tail nil)
2585 2989
2586(defvar ps-page-postscript 0) 2990(defvar ps-page-postscript 0)
2991(defvar ps-page-order 0)
2587(defvar ps-page-count 0) 2992(defvar ps-page-count 0)
2588(defvar ps-showline-count 1) 2993(defvar ps-showline-count 1)
2589 2994
@@ -2625,6 +3030,7 @@ This is in units of points (1/72 inch).")
2625 3030
2626(defmacro ps-page-dimensions-get-width (dims) `(nth 0 ,dims)) 3031(defmacro ps-page-dimensions-get-width (dims) `(nth 0 ,dims))
2627(defmacro ps-page-dimensions-get-height (dims) `(nth 1 ,dims)) 3032(defmacro ps-page-dimensions-get-height (dims) `(nth 1 ,dims))
3033(defmacro ps-page-dimensions-get-media (dims) `(nth 2 ,dims))
2628 3034
2629(defvar ps-landscape-page-height nil) 3035(defvar ps-landscape-page-height nil)
2630 3036
@@ -2764,7 +3170,7 @@ If EXTENSION is any other symbol, it is ignored."
2764 3170
2765 3171
2766;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3172;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2767;; Adapted from font-lock: 3173;; Adapted from font-lock: (obsolete stuff)
2768;; Originally face attributes were specified via `font-lock-face-attributes'. 3174;; Originally face attributes were specified via `font-lock-face-attributes'.
2769;; Users then changed the default face attributes by setting that variable. 3175;; Users then changed the default face attributes by setting that variable.
2770;; However, we try and be back-compatible and respect its value if set except 3176;; However, we try and be back-compatible and respect its value if set except
@@ -2809,6 +3215,7 @@ If EXTENSION is any other symbol, it is ignored."
2809 3215
2810 3216
2811(make-local-hook 'ps-print-hook) 3217(make-local-hook 'ps-print-hook)
3218(make-local-hook 'ps-print-begin-sheet-hook)
2812(make-local-hook 'ps-print-begin-page-hook) 3219(make-local-hook 'ps-print-begin-page-hook)
2813(make-local-hook 'ps-print-begin-column-hook) 3220(make-local-hook 'ps-print-begin-column-hook)
2814 3221
@@ -2835,7 +3242,7 @@ If EXTENSION is any other symbol, it is ignored."
2835 (ps-generate (current-buffer) from to 'ps-generate-postscript-with-faces)) 3242 (ps-generate (current-buffer) from to 'ps-generate-postscript-with-faces))
2836 3243
2837 3244
2838(defsubst ps-count-lines (from to) 3245(defun ps-count-lines (from to)
2839 (+ (count-lines from to) 3246 (+ (count-lines from to)
2840 (save-excursion 3247 (save-excursion
2841 (goto-char to) 3248 (goto-char to)
@@ -2843,19 +3250,25 @@ If EXTENSION is any other symbol, it is ignored."
2843 3250
2844 3251
2845(defvar ps-printing-region nil 3252(defvar ps-printing-region nil
2846 "Variable used to indicate if ps-print is printing a region. 3253 "Variable used to indicate if the region that ps-print is printing.
2847If non-nil, it is a cons, the car of which is the line number 3254It is a cons, the car of which is the line number where the region begins, and
2848where the region begins, and its cdr is the total number of lines 3255its cdr is the total number of lines in the buffer. Formatting functions can
2849in the buffer. Formatting functions can use this information 3256use this information to print the original line number (and not the number of
2850to print the original line number (and not the number of lines printed), 3257lines printed), and to indicate in the header that the printout is of a partial
2851and to indicate in the header that the printout is of a partial file.") 3258file.")
3259
3260
3261(defvar ps-printing-region-p nil
3262 "Non-nil means ps-print is printing a region.")
2852 3263
2853 3264
2854(defun ps-printing-region (region-p) 3265(defun ps-printing-region (region-p)
2855 (setq ps-printing-region 3266 (setq ps-printing-region-p region-p
2856 (and region-p 3267 ps-printing-region
2857 (cons (ps-count-lines (point-min) (region-beginning)) 3268 (cons (if region-p
2858 (ps-count-lines (point-min) (point-max)))))) 3269 (ps-count-lines (point-min) (region-beginning))
3270 1)
3271 (ps-count-lines (point-min) (point-max)))))
2859 3272
2860 3273
2861;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3274;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -3263,29 +3676,34 @@ page-height == bm + print-height + tm - ho - hh
3263 (setq count (1+ count))) 3676 (setq count (1+ count)))
3264 (ps-output "] def\n")))) 3677 (ps-output "] def\n"))))
3265 3678
3266(defun ps-output-boolean (name bool) 3679
3267 (ps-output (format "/%s %s def\n" name (if bool "true" "false")))) 3680(defun ps-output-boolean (name bool &optional no-def)
3681 (ps-output (format "/%s %s%s"
3682 name (if bool "true" "false") (if no-def "\n" " def\n"))))
3268 3683
3269 3684
3270(defun ps-background-pages (page-list func) 3685(defun ps-background-pages (page-list func)
3271 (if page-list 3686 (if page-list
3272 (mapcar 3687 (mapcar
3273 '(lambda (pages) 3688 #'(lambda (pages)
3274 (let ((start (if (consp pages) (car pages) pages)) 3689 (let ((start (if (consp pages) (car pages) pages))
3275 (end (if (consp pages) (cdr pages) pages))) 3690 (end (if (consp pages) (cdr pages) pages)))
3276 (and (integerp start) (integerp end) (<= start end) 3691 (and (integerp start) (integerp end) (<= start end)
3277 (add-to-list 'ps-background-pages (vector start end func))))) 3692 (add-to-list 'ps-background-pages (vector start end func)))))
3278 page-list) 3693 page-list)
3279 (setq ps-background-all-pages (cons func ps-background-all-pages)))) 3694 (setq ps-background-all-pages (cons func ps-background-all-pages))))
3280 3695
3281 3696
3697(defconst ps-boundingbox-re
3698 "^%%BoundingBox:\
3699\\s-+\\([0-9.]+\\)\\s-+\\([0-9.]+\\)\\s-+\\([0-9.]+\\)\\s-+\\([0-9.]+\\)")
3700
3701
3282(defun ps-get-boundingbox () 3702(defun ps-get-boundingbox ()
3283 (save-excursion 3703 (save-excursion
3284 (set-buffer ps-spool-buffer) 3704 (set-buffer ps-spool-buffer)
3285 (save-excursion 3705 (save-excursion
3286 (if (re-search-forward 3706 (if (re-search-forward ps-boundingbox-re nil t)
3287 "^%%BoundingBox:\\s-+\\([0-9.]+\\)\\s-+\\([0-9.]+\\)\\s-+\\([0-9.]+\\)\\s-+\\([0-9.]+\\)"
3288 nil t)
3289 (vector (string-to-number ; lower x 3707 (vector (string-to-number ; lower x
3290 (buffer-substring (match-beginning 1) (match-end 1))) 3708 (buffer-substring (match-beginning 1) (match-end 1)))
3291 (string-to-number ; lower y 3709 (string-to-number ; lower y
@@ -3318,77 +3736,78 @@ page-height == bm + print-height + tm - ho - hh
3318 3736
3319(defun ps-background-text () 3737(defun ps-background-text ()
3320 (mapcar 3738 (mapcar
3321 '(lambda (text) 3739 #'(lambda (text)
3322 (setq ps-background-text-count (1+ ps-background-text-count)) 3740 (setq ps-background-text-count (1+ ps-background-text-count))
3323 (ps-output (format "/ShowBackText-%d {\n" ps-background-text-count)) 3741 (ps-output (format "/ShowBackText-%d {\n" ps-background-text-count))
3324 (ps-output-string (nth 0 text)) ; text 3742 (ps-output-string (nth 0 text)) ; text
3325 (ps-output 3743 (ps-output
3326 "\n" 3744 "\n"
3327 (ps-float-format (nth 4 text) 200.0) ; font size 3745 (ps-float-format (nth 4 text) 200.0) ; font size
3328 (format "/%s " (or (nth 3 text) "Times-Roman")) ; font name 3746 (format "/%s " (or (nth 3 text) "Times-Roman")) ; font name
3329 (ps-float-format (nth 6 text) 3747 (ps-float-format (nth 6 text)
3330 "PrintHeight PrintPageWidth atan") ; rotation 3748 "PrintHeight PrintPageWidth atan") ; rotation
3331 (ps-float-format (nth 5 text) 0.85) ; gray 3749 (ps-float-format (nth 5 text) 0.85) ; gray
3332 (ps-float-format (nth 1 text) "0") ; x position 3750 (ps-float-format (nth 1 text) "0") ; x position
3333 (ps-float-format (nth 2 text) "BottomMargin") ; y position 3751 (ps-float-format (nth 2 text) "BottomMargin") ; y position
3334 "\nShowBackText} def\n") 3752 "\nShowBackText} def\n")
3335 (ps-background-pages (nthcdr 7 text) ; page list 3753 (ps-background-pages (nthcdr 7 text) ; page list
3336 (format "ShowBackText-%d\n" 3754 (format "ShowBackText-%d\n"
3337 ps-background-text-count))) 3755 ps-background-text-count)))
3338 ps-print-background-text)) 3756 ps-print-background-text))
3339 3757
3340 3758
3341(defun ps-background-image () 3759(defun ps-background-image ()
3342 (mapcar 3760 (mapcar
3343 '(lambda (image) 3761 #'(lambda (image)
3344 (let ((image-file (expand-file-name (nth 0 image)))) 3762 (let ((image-file (expand-file-name (nth 0 image))))
3345 (if (file-readable-p image-file) 3763 (if (file-readable-p image-file)
3346 (progn 3764 (progn
3347 (setq ps-background-image-count (1+ ps-background-image-count)) 3765 (setq ps-background-image-count (1+ ps-background-image-count))
3348 (ps-output 3766 (ps-output
3349 (format "/ShowBackImage-%d {\n--back-- " ps-background-image-count) 3767 (format "/ShowBackImage-%d {\n--back-- "
3350 (ps-float-format (nth 5 image) 0.0) ; rotation 3768 ps-background-image-count)
3351 (ps-float-format (nth 3 image) 1.0) ; x scale 3769 (ps-float-format (nth 5 image) 0.0) ; rotation
3352 (ps-float-format (nth 4 image) 1.0) ; y scale 3770 (ps-float-format (nth 3 image) 1.0) ; x scale
3353 (ps-float-format (nth 1 image) ; x position 3771 (ps-float-format (nth 4 image) 1.0) ; y scale
3354 "PrintPageWidth 2 div") 3772 (ps-float-format (nth 1 image) ; x position
3355 (ps-float-format (nth 2 image) ; y position 3773 "PrintPageWidth 2 div")
3356 "PrintHeight 2 div BottomMargin add") 3774 (ps-float-format (nth 2 image) ; y position
3357 "\nBeginBackImage\n") 3775 "PrintHeight 2 div BottomMargin add")
3358 (ps-insert-file image-file) 3776 "\nBeginBackImage\n")
3359 ;; coordinate adjustment to centralize image 3777 (ps-insert-file image-file)
3360 ;; around x and y position 3778 ;; coordinate adjustment to centralize image
3361 (let ((box (ps-get-boundingbox))) 3779 ;; around x and y position
3362 (save-excursion 3780 (let ((box (ps-get-boundingbox)))
3363 (set-buffer ps-spool-buffer) 3781 (save-excursion
3364 (save-excursion 3782 (set-buffer ps-spool-buffer)
3365 (if (re-search-backward "^--back--" nil t) 3783 (save-excursion
3366 (replace-match 3784 (if (re-search-backward "^--back--" nil t)
3367 (format "%s %s" 3785 (replace-match
3368 (ps-float-format 3786 (format "%s %s"
3369 (- (+ (/ (- (aref box 2) (aref box 0)) 2.0) 3787 (ps-float-format
3370 (aref box 0)))) 3788 (- (+ (/ (- (aref box 2) (aref box 0)) 2.0)
3371 (ps-float-format 3789 (aref box 0))))
3372 (- (+ (/ (- (aref box 3) (aref box 1)) 2.0) 3790 (ps-float-format
3373 (aref box 1))))) 3791 (- (+ (/ (- (aref box 3) (aref box 1)) 2.0)
3374 t))))) 3792 (aref box 1)))))
3375 (ps-output "\nEndBackImage} def\n") 3793 t)))))
3376 (ps-background-pages (nthcdr 6 image) ; page list 3794 (ps-output "\nEndBackImage} def\n")
3377 (format "ShowBackImage-%d\n" 3795 (ps-background-pages (nthcdr 6 image) ; page list
3378 ps-background-image-count)))))) 3796 (format "ShowBackImage-%d\n"
3797 ps-background-image-count))))))
3379 ps-print-background-image)) 3798 ps-print-background-image))
3380 3799
3381 3800
3382(defun ps-background (page-number) 3801(defun ps-background (page-number)
3383 (let (has-local-background) 3802 (let (has-local-background)
3384 (mapcar '(lambda (range) 3803 (mapcar #'(lambda (range)
3385 (and (<= (aref range 0) page-number) 3804 (and (<= (aref range 0) page-number)
3386 (<= page-number (aref range 1)) 3805 (<= page-number (aref range 1))
3387 (if has-local-background 3806 (if has-local-background
3388 (ps-output (aref range 2)) 3807 (ps-output (aref range 2))
3389 (setq has-local-background t) 3808 (setq has-local-background t)
3390 (ps-output "/printLocalBackground {\n" 3809 (ps-output "/printLocalBackground {\n"
3391 (aref range 2))))) 3810 (aref range 2)))))
3392 ps-background-pages) 3811 ps-background-pages)
3393 (and has-local-background (ps-output "} def\n")))) 3812 (and has-local-background (ps-output "} def\n"))))
3394 3813
@@ -3417,115 +3836,598 @@ page-height == bm + print-height + tm - ho - hh
3417 (and found index))) 3836 (and found index)))
3418 3837
3419 3838
3839(defconst ps-n-up-database
3840 '((a4
3841 (1 nil 1 1 0)
3842 (2 t 1 2 0)
3843 (4 nil 2 2 0)
3844 (6 t 2 3 1)
3845 (8 t 2 4 0)
3846 (9 nil 3 3 0)
3847 (12 t 3 4 2)
3848 (16 nil 4 4 0)
3849 (18 t 3 6 0)
3850 (20 nil 5 4 1)
3851 (25 nil 5 5 0)
3852 (30 nil 6 5 1)
3853 (32 t 4 8 0)
3854 (36 nil 6 6 0)
3855 (42 nil 7 6 1)
3856 (49 nil 7 7 0)
3857 (50 t 5 10 0)
3858 (56 nil 8 7 1)
3859 (64 nil 8 8 0)
3860 (72 nil 9 8 1)
3861 (81 nil 9 9 0)
3862 (90 nil 10 9 1)
3863 (100 nil 10 10 0))
3864 (a3
3865 (1 nil 1 1 0)
3866 (2 t 1 2 0)
3867 (4 nil 2 2 0)
3868 (6 t 2 3 1)
3869 (8 t 2 4 0)
3870 (9 nil 3 3 0)
3871 (12 nil 4 3 1)
3872 (16 nil 4 4 0)
3873 (18 t 3 6 0)
3874 (20 nil 5 4 1)
3875 (25 nil 5 5 0)
3876 (30 nil 6 5 1)
3877 (32 t 4 8 0)
3878 (36 nil 6 6 0)
3879 (42 nil 7 6 1)
3880 (49 nil 7 7 0)
3881 (50 t 5 10 0)
3882 (56 nil 8 7 1)
3883 (64 nil 8 8 0)
3884 (72 nil 9 8 1)
3885 (81 nil 9 9 0)
3886 (90 nil 10 9 1)
3887 (100 nil 10 10 0))
3888 (letter
3889 (1 nil 1 1 0)
3890 (4 nil 2 2 0)
3891 (6 t 2 3 0)
3892 (9 nil 3 3 0)
3893 (12 nil 4 3 1)
3894 (16 nil 4 4 0)
3895 (20 nil 5 4 1)
3896 (25 nil 5 5 0)
3897 (30 nil 6 5 1)
3898 (36 nil 6 6 0)
3899 (40 t 5 8 0)
3900 (42 nil 7 6 1)
3901 (49 nil 7 7 0)
3902 (56 nil 8 7 1)
3903 (64 nil 8 8 0)
3904 (72 nil 9 8 1)
3905 (81 nil 9 9 0)
3906 (90 nil 10 9 1)
3907 (100 nil 10 10 0))
3908 (legal
3909 (1 nil 1 1 0)
3910 (2 t 1 2 0)
3911 (4 nil 2 2 0)
3912 (6 nil 3 2 1)
3913 (9 nil 3 3 0)
3914 (10 t 2 5 0)
3915 (12 nil 4 3 1)
3916 (16 nil 4 4 0)
3917 (20 nil 5 4 1)
3918 (25 nil 5 5 0)
3919 (30 nil 6 5 1)
3920 (36 nil 6 6 0)
3921 (42 nil 7 6 1)
3922 (49 nil 7 7 0)
3923 (56 nil 8 7 1)
3924 (64 nil 8 8 0)
3925 (70 t 5 14 0)
3926 (72 nil 9 8 1)
3927 (81 nil 9 9 0)
3928 (90 nil 10 9 1)
3929 (100 nil 10 10 0))
3930 (letter-small
3931 (1 nil 1 1 0)
3932 (4 nil 2 2 0)
3933 (6 t 2 3 0)
3934 (9 nil 3 3 0)
3935 (12 t 3 4 1)
3936 (15 t 3 5 0)
3937 (16 nil 4 4 0)
3938 (20 nil 5 4 1)
3939 (25 nil 5 5 0)
3940 (28 t 4 7 0)
3941 (30 nil 6 5 1)
3942 (36 nil 6 6 0)
3943 (40 t 5 8 0)
3944 (42 nil 7 6 1)
3945 (49 nil 7 7 0)
3946 (56 nil 8 7 1)
3947 (60 t 6 10 0)
3948 (64 nil 8 8 0)
3949 (72 ni 9 8 1)
3950 (81 nil 9 9 0)
3951 (84 t 7 12 0)
3952 (90 nil 10 9 1)
3953 (100 nil 10 10 0))
3954 (tabloid
3955 (1 nil 1 1 0)
3956 (2 t 1 2 0)
3957 (4 nil 2 2 0)
3958 (6 t 2 3 1)
3959 (8 t 2 4 0)
3960 (9 nil 3 3 0)
3961 (12 nil 4 3 1)
3962 (16 nil 4 4 0)
3963 (20 nil 5 4 1)
3964 (25 nil 5 5 0)
3965 (30 nil 6 5 1)
3966 (36 nil 6 6 0)
3967 (42 nil 7 6 1)
3968 (49 nil 7 7 0)
3969 (56 nil 8 7 1)
3970 (64 nil 8 8 0)
3971 (72 nil 9 8 1)
3972 (81 nil 9 9 0)
3973 (84 t 6 14 0)
3974 (90 nil 10 9 1)
3975 (100 nil 10 10 0))
3976 ;; Ledger paper size is a special case, it is the only paper size where the
3977 ;; normal size is landscaped, that is, the height is smaller than width.
3978 ;; So, we use the special value `pag' in the `landscape' field.
3979 (ledger
3980 (1 nil 1 1 0)
3981 (2 pag 1 2 0)
3982 (4 nil 2 2 0)
3983 (6 pag 2 3 1)
3984 (8 pag 2 4 0)
3985 (9 nil 3 3 0)
3986 (12 nil 4 3 1)
3987 (16 nil 4 4 0)
3988 (20 nil 5 4 1)
3989 (25 nil 5 5 0)
3990 (30 nil 6 5 1)
3991 (36 nil 6 6 0)
3992 (42 nil 7 6 1)
3993 (49 nil 7 7 0)
3994 (56 nil 8 7 1)
3995 (64 nil 8 8 0)
3996 (72 nil 9 8 1)
3997 (81 nil 9 9 0)
3998 (84 pag 6 14 0)
3999 (90 nil 10 9 1)
4000 (100 nil 10 10 0))
4001 (statement
4002 (1 nil 1 1 0)
4003 (2 t 1 2 0)
4004 (4 nil 2 2 0)
4005 (6 nil 3 2 1)
4006 (9 nil 3 3 0)
4007 (10 t 2 5 0)
4008 (12 nil 4 3 1)
4009 (16 nil 4 4 0)
4010 (20 nil 5 4 1)
4011 (21 t 3 7 0)
4012 (25 nil 5 5 0)
4013 (30 nil 6 5 1)
4014 (36 nil 6 6 0)
4015 (40 t 4 10 0)
4016 (42 nil 7 6 1)
4017 (49 nil 7 7 0)
4018 (56 nil 8 7 1)
4019 (60 t 5 12 0)
4020 (64 nil 8 8 0)
4021 (72 nil 9 8 1)
4022 (81 nil 9 9 0)
4023 (90 nil 10 9 1)
4024 (100 nil 10 10 0))
4025 (executive
4026 (1 nil 1 1 0)
4027 (4 nil 2 2 0)
4028 (6 t 2 3 0)
4029 (9 nil 3 3 0)
4030 (12 nil 4 3 1)
4031 (16 nil 4 4 0)
4032 (20 nil 5 4 1)
4033 (25 nil 5 5 0)
4034 (28 t 4 7 0)
4035 (30 nil 6 5 1)
4036 (36 nil 6 6 0)
4037 (42 nil 7 6 1)
4038 (45 t 5 9 0)
4039 (49 nil 7 7 0)
4040 (56 nil 8 7 1)
4041 (60 t 6 10 0)
4042 (64 nil 8 8 0)
4043 (72 nil 9 8 1)
4044 (81 nil 9 9 0)
4045 (84 t 7 12 0)
4046 (90 nil 10 9 1)
4047 (100 nil 10 10 0))
4048 (a4small
4049 (1 nil 1 1 0)
4050 (2 t 1 2 0)
4051 (4 nil 2 2 0)
4052 (6 t 2 3 1)
4053 (8 t 2 4 0)
4054 (9 nil 3 3 0)
4055 (12 nil 4 3 1)
4056 (16 nil 4 4 0)
4057 (18 t 3 6 0)
4058 (20 nil 5 4 1)
4059 (25 nil 5 5 0)
4060 (30 nil 6 5 1)
4061 (32 t 4 8 0)
4062 (36 nil 6 6 0)
4063 (42 nil 7 6 1)
4064 (49 nil 7 7 0)
4065 (50 t 5 10 0)
4066 (56 nil 8 7 1)
4067 (64 nil 8 8 0)
4068 (72 nil 9 8 1)
4069 (78 t 6 13 0)
4070 (81 nil 9 9 0)
4071 (90 nil 10 9 1)
4072 (100 nil 10 10 0))
4073 (b4
4074 (1 nil 1 1 0)
4075 (2 t 1 2 0)
4076 (4 nil 2 2 0)
4077 (6 t 2 3 1)
4078 (8 t 2 4 0)
4079 (9 nil 3 3 0)
4080 (12 nil 4 3 1)
4081 (16 nil 4 4 0)
4082 (18 t 3 6 0)
4083 (20 nil 5 4 1)
4084 (25 nil 5 5 0)
4085 (30 nil 6 5 1)
4086 (32 t 4 8 0)
4087 (36 nil 6 6 0)
4088 (42 nil 7 6 1)
4089 (49 nil 7 7 0)
4090 (50 t 5 10 0)
4091 (56 nil 8 7 1)
4092 (64 nil 8 8 0)
4093 (72 nil 9 8 1)
4094 (81 nil 9 9 0)
4095 (90 nil 10 9 1)
4096 (100 nil 10 10 0))
4097 (b5
4098 (1 nil 1 1 0)
4099 (2 t 1 2 0)
4100 (4 nil 2 2 0)
4101 (6 t 2 3 1)
4102 (8 t 2 4 0)
4103 (9 nil 3 3 0)
4104 (12 nil 4 3 1)
4105 (16 nil 4 4 0)
4106 (18 t 3 6 0)
4107 (20 nil 5 4 1)
4108 (25 nil 5 5 0)
4109 (30 nil 6 5 1)
4110 (32 t 4 8 0)
4111 (36 nil 6 6 0)
4112 (42 nil 7 6 1)
4113 (49 nil 7 7 0)
4114 (50 t 5 10 0)
4115 (56 nil 8 7 1)
4116 (64 nil 8 8 0)
4117 (72 nil 9 8 0)
4118 (81 nil 9 9 0)
4119 (90 nil 10 9 1)
4120 (98 t 7 14 0)
4121 (100 nil 10 10 0)))
4122 "Alist which is the page matrix database used for N-up printing.
4123
4124Each element has the following form:
4125
4126 (PAGE
4127 (MAX LANDSCAPE LINES COLUMNS COL-MISSING)
4128 ...)
4129
4130Where:
4131PAGE is the page size used (see `ps-paper-type').
4132MAX is the maximum elements of this page matrix.
4133LANDSCAPE specifies if page matrix is landscaped, has the following valid
4134 values:
4135 nil the sheet is in portrait mode.
4136 t the sheet is in landscape mode.
4137 pag the sheet is in portrait mode and page is in landscape mode.
4138LINES is the number of lines of page matrix.
4139COLUMNS is the number of columns of page matrix.
4140COL-MISSING is the number of columns missing to fill the sheet.")
4141
4142
4143(defmacro ps-n-up-landscape (mat) `(nth 1 ,mat))
4144(defmacro ps-n-up-lines (mat) `(nth 2 ,mat))
4145(defmacro ps-n-up-columns (mat) `(nth 3 ,mat))
4146(defmacro ps-n-up-missing (mat) `(nth 4 ,mat))
4147
4148
4149(defun ps-n-up-printing ()
4150 ;; force `ps-n-up-printing' be in range 1 to 100.
4151 (setq ps-n-up-printing (max (min ps-n-up-printing 100) 1))
4152 ;; find suitable page matrix for a given `ps-paper-type'.
4153 (let ((the-list (cdr (assq ps-paper-type ps-n-up-database))))
4154 (and the-list
4155 (while (> ps-n-up-printing (caar the-list))
4156 (setq the-list (cdr the-list))))
4157 (car the-list)))
4158
4159
4160(defconst ps-n-up-filling-database
4161 '((left-top
4162 "PageWidth" ; N-Up-XColumn
4163 "0" ; N-Up-YColumn
4164 "N-Up-End 1 sub PageWidth mul neg" ; N-Up-XLine
4165 "LandscapePageHeight neg" ; N-Up-YLine
4166 "N-Up-Lines" ; N-Up-Repeat
4167 "N-Up-Columns" ; N-Up-End
4168 "0" ; N-Up-XStart
4169 "0") ; N-Up-YStart
4170 (left-bottom
4171 "PageWidth" ; N-Up-XColumn
4172 "0" ; N-Up-YColumn
4173 "N-Up-End 1 sub PageWidth mul neg" ; N-Up-XLine
4174 "LandscapePageHeight" ; N-Up-YLine
4175 "N-Up-Lines" ; N-Up-Repeat
4176 "N-Up-Columns" ; N-Up-End
4177 "0" ; N-Up-XStart
4178 "N-Up-Repeat 1 sub LandscapePageHeight mul neg") ; N-Up-YStart
4179 (right-top
4180 "PageWidth neg" ; N-Up-XColumn
4181 "0" ; N-Up-YColumn
4182 "N-Up-End 1 sub PageWidth mul" ; N-Up-XLine
4183 "LandscapePageHeight neg" ; N-Up-YLine
4184 "N-Up-Lines" ; N-Up-Repeat
4185 "N-Up-Columns" ; N-Up-End
4186 "N-Up-End 1 sub PageWidth mul" ; N-Up-XStart
4187 "0") ; N-Up-YStart
4188 (right-bottom
4189 "PageWidth neg" ; N-Up-XColumn
4190 "0" ; N-Up-YColumn
4191 "N-Up-End 1 sub PageWidth mul" ; N-Up-XLine
4192 "LandscapePageHeight" ; N-Up-YLine
4193 "N-Up-Lines" ; N-Up-Repeat
4194 "N-Up-Columns" ; N-Up-End
4195 "N-Up-End 1 sub PageWidth mul" ; N-Up-XStart
4196 "N-Up-Repeat 1 sub LandscapePageHeight mul neg") ; N-Up-YStart
4197 (top-left
4198 "0" ; N-Up-XColumn
4199 "LandscapePageHeight neg" ; N-Up-YColumn
4200 "PageWidth" ; N-Up-XLine
4201 "N-Up-End 1 sub LandscapePageHeight mul" ; N-Up-YLine
4202 "N-Up-Columns" ; N-Up-Repeat
4203 "N-Up-Lines" ; N-Up-End
4204 "0" ; N-Up-XStart
4205 "0") ; N-Up-YStart
4206 (bottom-left
4207 "0" ; N-Up-XColumn
4208 "LandscapePageHeight" ; N-Up-YColumn
4209 "PageWidth" ; N-Up-XLine
4210 "N-Up-End 1 sub LandscapePageHeight mul neg" ; N-Up-YLine
4211 "N-Up-Columns" ; N-Up-Repeat
4212 "N-Up-Lines" ; N-Up-End
4213 "0" ; N-Up-XStart
4214 "N-Up-End 1 sub LandscapePageHeight mul neg") ; N-Up-YStart
4215 (top-right
4216 "0" ; N-Up-XColumn
4217 "LandscapePageHeight neg" ; N-Up-YColumn
4218 "PageWidth neg" ; N-Up-XLine
4219 "N-Up-End 1 sub LandscapePageHeight mul" ; N-Up-YLine
4220 "N-Up-Columns" ; N-Up-Repeat
4221 "N-Up-Lines" ; N-Up-End
4222 "N-Up-Repeat 1 sub PageWidth mul" ; N-Up-XStart
4223 "0") ; N-Up-YStart
4224 (bottom-right
4225 "0" ; N-Up-XColumn
4226 "LandscapePageHeight" ; N-Up-YColumn
4227 "PageWidth neg" ; N-Up-XLine
4228 "N-Up-End 1 sub LandscapePageHeight mul neg" ; N-Up-YLine
4229 "N-Up-Columns" ; N-Up-Repeat
4230 "N-Up-Lines" ; N-Up-End
4231 "N-Up-Repeat 1 sub PageWidth mul" ; N-Up-XStart
4232 "N-Up-End 1 sub LandscapePageHeight mul neg")) ; N-Up-YStart
4233 "Alist for n-up printing initializations.
4234
4235Each element has the following form:
4236
4237 (KIND XCOL YCOL XLIN YLIN REPEAT END XSTART YSTART)
4238
4239Where:
4240KIND is a valid value of `ps-n-up-filling'.
4241XCOL YCOL are the relative position for the next column.
4242XLIN YLIN are the relative position for the beginning of next line.
4243REPEAT is the number of repetions for external loop.
4244END is the number of repetions for internal loop and also the number of pages in
4245 a row.
4246XSTART YSTART are the relative position for the first page in a sheet.")
4247
4248
4249(defun ps-n-up-filling ()
4250 (cdr (or (assq ps-n-up-filling ps-n-up-filling-database)
4251 (assq 'left-top ps-n-up-filling-database))))
4252
4253
4254(defmacro ps-n-up-xcolumn (init) `(nth 0 ,init))
4255(defmacro ps-n-up-ycolumn (init) `(nth 1 ,init))
4256(defmacro ps-n-up-xline (init) `(nth 2 ,init))
4257(defmacro ps-n-up-yline (init) `(nth 3 ,init))
4258(defmacro ps-n-up-repeat (init) `(nth 4 ,init))
4259(defmacro ps-n-up-end (init) `(nth 5 ,init))
4260(defmacro ps-n-up-xstart (init) `(nth 6 ,init))
4261(defmacro ps-n-up-ystart (init) `(nth 7 ,init))
4262
4263
3420(defun ps-begin-file () 4264(defun ps-begin-file ()
3421 (ps-get-page-dimensions) 4265 (ps-get-page-dimensions)
3422 (setq ps-page-postscript 0 4266 (setq ps-page-postscript 0
4267 ps-page-order 0
3423 ps-background-text-count 0 4268 ps-background-text-count 0
3424 ps-background-image-count 0 4269 ps-background-image-count 0
3425 ps-background-pages nil 4270 ps-background-pages nil
3426 ps-background-all-pages nil) 4271 ps-background-all-pages nil)
3427 4272
3428 (ps-output ps-adobe-tag 4273 (let ((dimensions (cdr (assq ps-paper-type ps-page-dimensions-database)))
3429 "%%Title: " (buffer-name) ; Take job name from name of 4274 (tumble (if ps-landscape-mode (not ps-spool-tumble) ps-spool-tumble))
4275 (n-up (ps-n-up-printing))
4276 (n-up-filling (ps-n-up-filling)))
4277 (and (> ps-n-up-printing 1) (setq tumble (not tumble)))
4278 (ps-output
4279 ps-adobe-tag
4280 "%%Title: " (buffer-name) ; Take job name from name of
3430 ; first buffer printed 4281 ; first buffer printed
3431 "\n%%Creator: " (user-full-name) 4282 "\n%%Creator: " (user-full-name)
3432 " (using ps-print v" ps-print-version 4283 " (using ps-print v" ps-print-version
3433 ")\n%%CreationDate: " 4284 ")\n%%CreationDate: "
3434 (time-stamp-hh:mm:ss) " " (time-stamp-mon-dd-yyyy) 4285 (time-stamp-hh:mm:ss) " " (time-stamp-mon-dd-yyyy)
3435 "\n%%Orientation: " 4286 "\n%%Orientation: "
3436 (if ps-landscape-mode "Landscape" "Portrait") 4287 (if ps-landscape-mode "Landscape" "Portrait")
3437 "\n%%DocumentNeededResources: font Times-Roman Times-Italic\n%%+ font " 4288 "\n%%DocumentNeededResources: font Times-Roman Times-Italic\n%%+ font "
3438 (mapconcat 'identity 4289 (mapconcat 'identity
3439 (ps-remove-duplicates 4290 (ps-remove-duplicates
3440 (append (ps-fonts 'ps-font-for-text) 4291 (append (ps-fonts 'ps-font-for-text)
3441 (list (ps-font 'ps-font-for-header 'normal) 4292 (list (ps-font 'ps-font-for-header 'normal)
3442 (ps-font 'ps-font-for-header 'bold)))) 4293 (ps-font 'ps-font-for-header 'bold))))
3443 "\n%%+ font ") 4294 "\n%%+ font ")
3444 "\n%%Pages: (atend)\n%%Requirements:" 4295 "\n%%DocumentMedia: " (ps-page-dimensions-get-media dimensions)
3445 (if ps-spool-duplex " duplex\n" "\n")) 4296 (format " %d" (round (ps-page-dimensions-get-width dimensions)))
3446 4297 (format " %d" (round (ps-page-dimensions-get-height dimensions)))
3447 (let ((comments (if (functionp ps-print-prologue-header) 4298 " 0 () ()\n%%PageOrder: Ascend\n%%Pages: (atend)\n%%Requirements:"
3448 (funcall ps-print-prologue-header) 4299 (if ps-spool-duplex
3449 ps-print-prologue-header))) 4300 (format " duplex%s" (if tumble "(tumble)\n" "\n"))
3450 (and (stringp comments) 4301 "\n"))
3451 (ps-output comments))) 4302
3452 4303 (let ((comments (if (functionp ps-print-prologue-header)
3453 (ps-output "%%EndComments\n\n%%BeginPrologue\n\n") 4304 (funcall ps-print-prologue-header)
3454 4305 ps-print-prologue-header)))
3455 (ps-output-boolean "LandscapeMode" ps-landscape-mode) 4306 (and (stringp comments)
3456 (ps-output (format "/NumberOfColumns %d def\n" ps-number-of-columns) 4307 (ps-output comments)))
3457 4308
3458 (format "/LandscapePageHeight %s def\n" ps-landscape-page-height) 4309 (ps-output "%%EndComments\n\n%%BeginPrologue\n\n"
3459 (format "/PrintPageWidth %s def\n" 4310 "/gs_languagelevel /languagelevel where {pop languagelevel}{1}ifelse def\n\n")
3460 (- (* (+ ps-print-width ps-inter-column) 4311
3461 ps-number-of-columns) 4312 (ps-output-boolean "SkipFirstPage " ps-banner-page-when-duplexing)
3462 ps-inter-column)) 4313 (ps-output-boolean "LandscapeMode "
3463 (format "/PrintWidth %s def\n" ps-print-width) 4314 (or ps-landscape-mode
3464 (format "/PrintHeight %s def\n" ps-print-height) 4315 (eq (ps-n-up-landscape n-up) 'pag)))
3465 4316 (ps-output (format "/NumberOfColumns %d def\n" ps-number-of-columns)
3466 (format "/LeftMargin %s def\n" ps-left-margin) 4317
3467 (format "/RightMargin %s def\n" ps-right-margin) ; not used 4318 (format "/LandscapePageHeight %s def\n" ps-landscape-page-height)
3468 (format "/InterColumn %s def\n" ps-inter-column) 4319 (format "/PrintPageWidth %s def\n"
3469 4320 (- (* (+ ps-print-width ps-inter-column)
3470 (format "/BottomMargin %s def\n" ps-bottom-margin) 4321 ps-number-of-columns)
3471 (format "/TopMargin %s def\n" ps-top-margin) ; not used 4322 ps-inter-column))
3472 (format "/HeaderOffset %s def\n" ps-header-offset) 4323 (format "/PrintWidth %s def\n" ps-print-width)
3473 (format "/HeaderPad %s def\n" ps-header-pad)) 4324 (format "/PrintHeight %s def\n" ps-print-height)
3474 4325
3475 (ps-output-boolean "PrintHeader" ps-print-header) 4326 (format "/LeftMargin %s def\n" ps-left-margin)
3476 (ps-output-boolean "PrintOnlyOneHeader" ps-print-only-one-header) 4327 (format "/RightMargin %s def\n" ps-right-margin)
3477 (ps-output-boolean "PrintHeaderFrame" ps-print-header-frame) 4328 (format "/InterColumn %s def\n" ps-inter-column)
3478 (ps-output-boolean "ShowNofN" ps-show-n-of-n) 4329
3479 (ps-output-boolean "Duplex" ps-spool-duplex) 4330 (format "/BottomMargin %s def\n" ps-bottom-margin)
3480 4331 (format "/TopMargin %s def\n" ps-top-margin) ; not used
3481 (let ((line-height (ps-line-height 'ps-font-for-text))) 4332 (format "/HeaderOffset %s def\n" ps-header-offset)
3482 (ps-output (format "/LineHeight %s def\n" line-height) 4333 (format "/HeaderPad %s def\n" ps-header-pad))
3483 (format "/LinesPerColumn %d def\n" 4334
3484 (round (/ (+ ps-print-height 4335 (ps-output-boolean "PrintHeader " ps-print-header)
3485 (* line-height 0.45)) 4336 (ps-output-boolean "PrintOnlyOneHeader" ps-print-only-one-header)
3486 line-height))))) 4337 (ps-output-boolean "PrintHeaderFrame " ps-print-header-frame)
3487 4338 (ps-output-boolean "ShowNofN " ps-show-n-of-n)
3488 (ps-output-boolean "Zebra" ps-zebra-stripes) 4339 (ps-output-boolean "DuplexValue " ps-spool-duplex)
3489 (ps-output-boolean "PrintLineNumber" ps-line-number) 4340 (ps-output-boolean "TumbleValue " tumble)
3490 (ps-output (format "/ZebraHeight %d def\n" ps-zebra-stripe-height)) 4341
3491 4342 (let ((line-height (ps-line-height 'ps-font-for-text)))
3492 (ps-background-text) 4343 (ps-output (format "/LineHeight %s def\n" line-height)
3493 (ps-background-image) 4344 (format "/LinesPerColumn %d def\n"
3494 (setq ps-background-all-pages (nreverse ps-background-all-pages) 4345 (round (/ (+ ps-print-height
3495 ps-background-pages (nreverse ps-background-pages)) 4346 (* line-height 0.45))
3496 4347 line-height)))))
3497 (ps-output ps-print-prologue-1) 4348
3498 4349 (ps-output-boolean "Zebra " ps-zebra-stripes)
3499 (ps-output "/printGlobalBackground {\n") 4350 (ps-output-boolean "PrintLineNumber " ps-line-number)
3500 (ps-output-list ps-background-all-pages) 4351 (ps-output (format "/ZebraHeight %d def\n" ps-zebra-stripe-height)
3501 (ps-output "} def\n/printLocalBackground {\n} def\n") 4352 (format "/ZebraGray %s def\n" ps-zebra-gray)
3502 4353 "/UseSetpagedevice "
3503 ;; Header fonts 4354 (if (eq ps-spool-config 'setpagedevice)
3504 (ps-output (format "/h0 %s (%s) cvn DefFont\n" ; /h0 14 /Helvetica-Bold DefFont 4355 "/setpagedevice where {pop true}{false}ifelse def\n"
3505 ps-header-title-font-size-internal 4356 "false def\n")
3506 (ps-font 'ps-font-for-header 'bold)) 4357 "\n/PageWidth "
3507 (format "/h1 %s (%s) cvn DefFont\n" ; /h1 12 /Helvetica DefFont 4358 "PrintPageWidth LeftMargin add RightMargin add def\n\n"
3508 ps-header-font-size-internal 4359 (format "/N-Up %d def\n" ps-n-up-printing))
3509 (ps-font 'ps-font-for-header 'normal))) 4360 (ps-output-boolean "N-Up-Landscape" (eq (ps-n-up-landscape n-up) t))
3510 4361 (ps-output-boolean "N-Up-Border " ps-n-up-border-p)
3511 (ps-output ps-print-prologue-2) 4362 (ps-output (format "/N-Up-Lines %d def\n" (ps-n-up-lines n-up))
3512 4363 (format "/N-Up-Columns %d def\n" (ps-n-up-columns n-up))
3513 ;; Text fonts 4364 (format "/N-Up-Missing %d def\n" (ps-n-up-missing n-up))
3514 (let ((font (ps-font-alist 'ps-font-for-text)) 4365 (format "/N-Up-Margin %s" ps-n-up-margin)
3515 (i 0)) 4366 " def\n/N-Up-Repeat "
3516 (while font 4367 (if ps-landscape-mode
3517 (ps-output (format "/f%d %s (%s) cvn DefFont\n" 4368 (ps-n-up-end n-up-filling)
3518 i 4369 (ps-n-up-repeat n-up-filling))
3519 ps-font-size-internal 4370 " def\n/N-Up-End "
3520 (ps-font 'ps-font-for-text (car (car font))))) 4371 (if ps-landscape-mode
3521 (setq font (cdr font) 4372 (ps-n-up-repeat n-up-filling)
3522 i (1+ i)))) 4373 (ps-n-up-end n-up-filling))
3523 4374 " def\n/N-Up-XColumn " (ps-n-up-xcolumn n-up-filling)
3524 (let ((font-entry (cdr (assq ps-font-family ps-font-info-database)))) 4375 " def\n/N-Up-YColumn " (ps-n-up-ycolumn n-up-filling)
3525 (ps-output (format "/SpaceWidthRatio %f def\n" 4376 " def\n/N-Up-XLine " (ps-n-up-xline n-up-filling)
3526 (/ (ps-lookup 'space-width) (ps-lookup 'size))))) 4377 " def\n/N-Up-YLine " (ps-n-up-yline n-up-filling)
3527 4378 " def\n/N-Up-XStart " (ps-n-up-xstart n-up-filling)
3528 (ps-output "\n%%EndPrologue\n\n%%BeginSetup\nBeginDoc\n%%EndSetup\n")) 4379 " def\n/N-Up-YStart " (ps-n-up-ystart n-up-filling) " def\n")
4380
4381 (ps-background-text)
4382 (ps-background-image)
4383 (setq ps-background-all-pages (nreverse ps-background-all-pages)
4384 ps-background-pages (nreverse ps-background-pages))
4385
4386 (ps-output ps-print-prologue-1)
4387
4388 (ps-output "/printGlobalBackground {\n")
4389 (ps-output-list ps-background-all-pages)
4390 (ps-output "} def\n/printLocalBackground {\n} def\n")
4391
4392 ;; Header fonts
4393 (ps-output (format "/h0 %s (%s) cvn DefFont\n" ; /h0 14 /Helvetica-Bold DefFont
4394 ps-header-title-font-size-internal
4395 (ps-font 'ps-font-for-header 'bold))
4396 (format "/h1 %s (%s) cvn DefFont\n" ; /h1 12 /Helvetica DefFont
4397 ps-header-font-size-internal
4398 (ps-font 'ps-font-for-header 'normal)))
4399
4400 (ps-output ps-print-prologue-2)
4401
4402 ;; Text fonts
4403 (let ((font (ps-font-alist 'ps-font-for-text))
4404 (i 0))
4405 (while font
4406 (ps-output (format "/f%d %s (%s) cvn DefFont\n"
4407 i
4408 ps-font-size-internal
4409 (ps-font 'ps-font-for-text (car (car font)))))
4410 (setq font (cdr font)
4411 i (1+ i))))
4412
4413 (let ((font-entry (cdr (assq ps-font-family ps-font-info-database))))
4414 (ps-output (format "/SpaceWidthRatio %f def\n"
4415 (/ (ps-lookup 'space-width) (ps-lookup 'size)))))
4416
4417 (ps-output "\n%%EndPrologue\n\n%%BeginSetup\n")
4418 (unless (eq ps-spool-config 'lpr-switches)
4419 (ps-output "\n%%BeginFeature: *Duplex "
4420 (ps-boolean-capitalized ps-spool-duplex)
4421 " *Tumble "
4422 (ps-boolean-capitalized tumble)
4423 ps-print-duplex-feature
4424 "%%EndFeature\n")))
4425 (ps-output "\n/Lines 0 def\n/PageCount 0 def\n\nBeginDoc\n%%EndSetup\n"))
4426
4427
4428(defun ps-boolean-capitalized (bool)
4429 (if bool "True" "False"))
4430
3529 4431
3530(defun ps-header-dirpart () 4432(defun ps-header-dirpart ()
3531 (let ((fname (buffer-file-name))) 4433 (let ((fname (buffer-file-name)))
@@ -3535,6 +4437,7 @@ page-height == bm + print-height + tm - ho - hh
3535 fname) 4437 fname)
3536 ""))) 4438 "")))
3537 4439
4440
3538(defun ps-get-buffer-name () 4441(defun ps-get-buffer-name ()
3539 (cond 4442 (cond
3540 ;; Indulge Jim this little easter egg: 4443 ;; Indulge Jim this little easter egg:
@@ -3544,7 +4447,7 @@ page-height == bm + print-height + tm - ho - hh
3544 ((string= (buffer-name) "sokoban.el") 4447 ((string= (buffer-name) "sokoban.el")
3545 "Super! C'est sokoban.el!") 4448 "Super! C'est sokoban.el!")
3546 (t (concat 4449 (t (concat
3547 (and ps-printing-region "Subset of: ") 4450 (and ps-printing-region-p "Subset of: ")
3548 (buffer-name) 4451 (buffer-name)
3549 (and (buffer-modified-p) " (unsaved)"))))) 4452 (and (buffer-modified-p) " (unsaved)")))))
3550 4453
@@ -3569,7 +4472,7 @@ page-height == bm + print-height + tm - ho - hh
3569 (goto-char (point-max)) 4472 (goto-char (point-max))
3570 (and (re-search-backward "^%%Trailer$" nil t) 4473 (and (re-search-backward "^%%Trailer$" nil t)
3571 (delete-region (match-beginning 0) (point-max)))) 4474 (delete-region (match-beginning 0) (point-max))))
3572 (setq ps-showline-count (if ps-printing-region (car ps-printing-region) 1) 4475 (setq ps-showline-count (car ps-printing-region)
3573 ps-page-count 0 4476 ps-page-count 0
3574 ps-font-size-internal (ps-get-font-size 'ps-font-size) 4477 ps-font-size-internal (ps-get-font-size 'ps-font-size)
3575 ps-header-font-size-internal (ps-get-font-size 'ps-header-font-size) 4478 ps-header-font-size-internal (ps-get-font-size 'ps-header-font-size)
@@ -3588,8 +4491,21 @@ page-height == bm + print-height + tm - ho - hh
3588 `(1+ (/ (1- ps-page-count) ps-number-of-columns))) 4491 `(1+ (/ (1- ps-page-count) ps-number-of-columns)))
3589 4492
3590(defun ps-end-file () 4493(defun ps-end-file ()
3591 (ps-output "\n%%Trailer\n%%Pages: " 4494 ;; Back to the PS output buffer to set the last page n-up printing
3592 (format "%d" ps-page-postscript) 4495 (save-excursion
4496 (let ((pages-per-sheet (mod ps-page-postscript ps-n-up-printing))
4497 case-fold-search)
4498 (set-buffer ps-spool-buffer)
4499 (goto-char (point-max))
4500 (and (> pages-per-sheet 0)
4501 (re-search-backward "^[0-9]+ BeginSheet$" nil t)
4502 (replace-match (format "%d BeginSheet" pages-per-sheet) t))))
4503 ;; Set dummy page
4504 (and ps-spool-duplex (= (mod ps-page-order 2) 1)
4505 (ps-dummy-page))
4506 ;; Set end of PostScript file
4507 (ps-output "EndSheet\n\n%%Trailer\n%%Pages: "
4508 (format "%d" ps-page-order)
3593 "\n\nEndDoc\n\n%%EOF\n")) 4509 "\n\nEndDoc\n\n%%EOF\n"))
3594 4510
3595 4511
@@ -3598,23 +4514,39 @@ page-height == bm + print-height + tm - ho - hh
3598 (ps-flush-output) 4514 (ps-flush-output)
3599 (ps-begin-page)) 4515 (ps-begin-page))
3600 4516
3601(defun ps-header-page () 4517
4518(defun ps-header-sheet ()
4519 ;; Print only when a new sheet begins.
4520 (setq ps-page-postscript (1+ ps-page-postscript)
4521 ps-page-order (1+ ps-page-order))
4522 (and (> ps-page-order 1)
4523 (ps-output "EndSheet\n"))
4524 (ps-output (format "\n%%%%Page: %d %d\n"
4525 ps-page-postscript ps-page-order))
4526 (ps-output (format "%d BeginSheet\nBeginDSCPage\n" ps-n-up-printing)))
4527
4528
4529(defsubst ps-header-page ()
3602 ;; set total line and page number when printing has finished 4530 ;; set total line and page number when printing has finished
3603 ;; (see `ps-generate') 4531 ;; (see `ps-generate')
3604 (if (prog1 4532 (run-hooks
3605 (zerop (mod ps-page-count ps-number-of-columns)) 4533 (if (prog1
3606 (setq ps-page-count (1+ ps-page-count))) 4534 (zerop (mod ps-page-count ps-number-of-columns))
3607 ;; Print only when a new real page begins. 4535 (setq ps-page-count (1+ ps-page-count)))
3608 (progn 4536 (prog1
3609 (setq ps-page-postscript (1+ ps-page-postscript)) 4537 (if (zerop (mod ps-page-postscript ps-n-up-printing))
3610 (ps-output (format "\n%%%%Page: %d %d\n" 4538 ;; Print only when a new sheet begins.
3611 ps-page-postscript ps-page-postscript)) 4539 (progn
3612 (ps-output "/Lines 0 def\n/PageCount 0 def\nBeginDSCPage\n") 4540 (ps-header-sheet)
3613 (ps-background ps-page-postscript) 4541 'ps-print-begin-sheet-hook)
3614 (run-hooks 'ps-print-begin-page-hook)) 4542 ;; Print only when a new page begins.
3615 ;; Print when any other page begins. 4543 (setq ps-page-postscript (1+ ps-page-postscript))
3616 (ps-output "/Lines 0 def\n/PageCount 0 def\nBeginDSCPage\n") 4544 (ps-output "BeginDSCPage\n")
3617 (run-hooks 'ps-print-begin-column-hook))) 4545 'ps-print-begin-page-hook)
4546 (ps-background ps-page-postscript))
4547 ;; Print only when a new column begins.
4548 (ps-output "BeginDSCPage\n")
4549 'ps-print-begin-column-hook)))
3618 4550
3619(defun ps-begin-page () 4551(defun ps-begin-page ()
3620 (ps-get-page-dimensions) 4552 (ps-get-page-dimensions)
@@ -3643,11 +4575,15 @@ page-height == bm + print-height + tm - ho - hh
3643 (ps-output "EndPage\nEndDSCPage\n")) 4575 (ps-output "EndPage\nEndDSCPage\n"))
3644 4576
3645(defun ps-dummy-page () 4577(defun ps-dummy-page ()
3646 (ps-header-page) 4578 (let ((ps-n-up-printing 0))
4579 (ps-header-sheet))
3647 (ps-output "/PrintHeader false def 4580 (ps-output "/PrintHeader false def
4581/ColumnIndex 0 def
4582/PrintLineNumber false def
3648BeginPage 4583BeginPage
3649EndPage 4584EndPage
3650EndDSCPage\n")) 4585EndDSCPage\n")
4586 (setq ps-page-postscript ps-n-up-printing))
3651 4587
3652(defun ps-next-line () 4588(defun ps-next-line ()
3653 (setq ps-showline-count (1+ ps-showline-count)) 4589 (setq ps-showline-count (1+ ps-showline-count))
@@ -3868,7 +4804,8 @@ EndDSCPage\n"))
3868 (if (color-specifier-p x-color) 4804 (if (color-specifier-p x-color)
3869 (color-name x-color) 4805 (color-name x-color)
3870 x-color))))) 4806 x-color)))))
3871 (t (error "No available function to determine X color values.")))) 4807 (t
4808 (error "No available function to determine X color values."))))
3872 )) 4809 ))
3873 4810
3874 4811
@@ -4220,24 +5157,9 @@ If FACE is not a valid face name, it is used default face."
4220 (funcall genfunc from to) 5157 (funcall genfunc from to)
4221 (ps-end-page) 5158 (ps-end-page)
4222 5159
4223 (and ps-spool-duplex (= (mod ps-page-count 2) 1)
4224 (ps-dummy-page))
4225 (ps-end-file) 5160 (ps-end-file)
4226 (ps-flush-output) 5161 (ps-flush-output)
4227 5162 (ps-end-job)
4228 ;; Back to the PS output buffer to set the page count
4229 (let ((total-lines (if ps-printing-region
4230 (cdr ps-printing-region)
4231 (ps-count-lines (point-min) (point-max))))
4232 (total-pages (if ps-print-only-one-header
4233 (ps-page-number)
4234 ps-page-count)))
4235 (set-buffer ps-spool-buffer)
4236 (goto-char (point-min))
4237 (while (re-search-forward "^/Lines 0 def\n/PageCount 0 def$"
4238 nil t)
4239 (replace-match (format "/Lines %d def\n/PageCount %d def"
4240 total-lines total-pages) t)))
4241 5163
4242 ;; Setting this variable tells the unwind form that the 5164 ;; Setting this variable tells the unwind form that the
4243 ;; the PostScript was generated without error. 5165 ;; the PostScript was generated without error.
@@ -4255,8 +5177,18 @@ If FACE is not a valid face name, it is used default face."
4255 (and ps-razzle-dazzle (message "Formatting...done")))))) 5177 (and ps-razzle-dazzle (message "Formatting...done"))))))
4256 5178
4257 5179
4258;; to avoid compilation gripes. 5180(defun ps-end-job ()
4259(defvar dos-ps-printer nil) 5181 (let ((total-lines (cdr ps-printing-region))
5182 (total-pages (if ps-print-only-one-header
5183 (ps-page-number)
5184 ps-page-count))
5185 case-fold-search)
5186 (set-buffer ps-spool-buffer)
5187 ;; Back to the PS output buffer to set the page count
5188 (goto-char (point-min))
5189 (and (re-search-forward "^/Lines 0 def\n/PageCount 0 def$" nil t)
5190 (replace-match (format "/Lines %d def\n/PageCount %d def"
5191 total-lines total-pages) t))))
4260 5192
4261 5193
4262;; Permit dynamic evaluation at print time of `ps-lpr-switches'. 5194;; Permit dynamic evaluation at print time of `ps-lpr-switches'.
@@ -4281,10 +5213,9 @@ If FACE is not a valid face name, it is used default face."
4281 (and (boundp 'printer-name) 5213 (and (boundp 'printer-name)
4282 printer-name))) 5214 printer-name)))
4283 (ps-lpr-switches 5215 (ps-lpr-switches
4284 (append 5216 (append (and (stringp ps-printer-name)
4285 (and (stringp ps-printer-name) 5217 (list (concat "-P" ps-printer-name)))
4286 (list (concat "-P" ps-printer-name))) 5218 ps-lpr-switches)))
4287 ps-lpr-switches)))
4288 (apply (or ps-print-region-function 'call-process-region) 5219 (apply (or ps-print-region-function 'call-process-region)
4289 (point-min) (point-max) ps-lpr-command nil 5220 (point-min) (point-max) ps-lpr-command nil
4290 (and (fboundp 'start-process) 0) 5221 (and (fboundp 'start-process) 0)