1 % Copyright (C) 1989, 2000 Aladdin Enterprises. All rights reserved.
3 % This software is provided AS-IS with no warranty, either express or
6 % This software is distributed under license and may not be copied,
7 % modified or distributed except as expressly authorized under the terms
8 % of the license contained in the file LICENSE in this distribution.
10 % For more information about licensing, please refer to
11 % http://www.ghostscript.com/licensing/. For information on
12 % commercial licensing, go to http://www.artifex.com/licensing/ or
13 % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14 % San Rafael, CA 94903, U.S.A., +1(415)492-9861.
16 % $Id: gs_statd.ps,v 1.14 2003/12/17 09:45:58 ray Exp $
17 % This file provides statusdict, serverdict, and assorted LaserWriter
18 % operators, mostly for the benefit of poorly designed PostScript programs
19 % that 'know' they are running on a LaserWriter.
22 % We make statusdict a little larger for Level 2 stuff.
23 % Note that it must be allocated in local VM.
24 .currentglobal false .setglobal
25 /statusdict 89 dict .forcedef % statusdict is local, sys'dict global
26 % To support the Level 2 job control features,
27 % serverdict must also be in local VM.
28 /serverdict 10 dict .forcedef % serverdict is local, sys'dict global
32 % Define various paper formats. The Adobe documentation defines only these:
33 % 11x17, a3, a4, a4small, b5, ledger, legal, letter, lettersmall, note.
34 % These procedures are also accessed as data structures during initialization,
35 % so the page dimensions must be the first two elements of the procedure.
37 /.setpagesize { /statusdict .systemvar begin .setpagesize end } bind def
39 % Page sizes defined by Adobe documentation
40 % Note: these executable arrays should all begin with two
41 % integers which are the width and height (see gs_setpd.ps).
42 /11x17 {792 1224 //.setpagesize exec} bind def % 11x17 portrait
43 /a3 {842 1191 //.setpagesize exec} bind def
44 /a4 {595 842 //.setpagesize exec} bind def
45 % a4small should be a4 with an ImagingBBox of [25 25 570 817].
48 /ledger {1224 792 //.setpagesize exec} bind def % 11x17 landscape
49 /legal {612 1008 //.setpagesize exec} bind def
50 /letter {612 792 //.setpagesize exec} bind def
51 % lettersmall should be letter with an ImagingBBox of [25 25 587 767].
52 /lettersmall /letter load def
53 % note should be letter (or some other size) with the ImagingBBox
54 % shrunk by 25 units on all 4 sides.
55 /note /letter load def
56 % End of Adobe-defined page sizes
57 STRICT { (%END SIZES) .skipeof } if
59 % ISO standard paper sizes
60 /a0 {2384 3370 //.setpagesize exec} bind def
61 /a1 {1684 2384 //.setpagesize exec} bind def
62 /a2 {1191 1684 //.setpagesize exec} bind def
63 % /a3 {842 1191 //.setpagesize exec} bind def % defined by Adobe
64 % /a4 {595 842 //.setpagesize exec} bind def % defined by Adobe
65 /a5 {420 595 //.setpagesize exec} bind def
66 /a6 {297 420 //.setpagesize exec} bind def
67 /a7 {210 297 //.setpagesize exec} bind def
68 /a8 {148 210 //.setpagesize exec} bind def
69 /a9 {105 148 //.setpagesize exec} bind def
70 /a10 {73 105 //.setpagesize exec} bind def
71 % ISO and JIS B sizes are different....
72 /isob0 {2835 4008 //.setpagesize exec} bind def
74 /isob1 {2004 2835 //.setpagesize exec} bind def
76 /isob2 {1417 2004 //.setpagesize exec} bind def
78 /isob3 {1001 1417 //.setpagesize exec} bind def
80 /isob4 {709 1001 //.setpagesize exec} bind def
82 /isob5 {499 709 //.setpagesize exec} bind def
84 /isob6 {354 499 //.setpagesize exec} bind def
86 /jisb0 {2920 4127 //.setpagesize exec} bind def
87 /jisb1 {2064 2920 //.setpagesize exec} bind def
88 /jisb2 {1460 2064 //.setpagesize exec} bind def
89 /jisb3 {1032 1460 //.setpagesize exec} bind def
90 /jisb4 {729 1032 //.setpagesize exec} bind def
91 /jisb5 {516 729 //.setpagesize exec} bind def
92 /jisb6 {363 516 //.setpagesize exec} bind def
93 /c0 {2599 3677 //.setpagesize exec} bind def
94 /c1 {1837 2599 //.setpagesize exec} bind def
95 /c2 {1298 1837 //.setpagesize exec} bind def
96 /c3 {918 1298 //.setpagesize exec} bind def
97 /c4 {649 918 //.setpagesize exec} bind def
98 /c5 {459 649 //.setpagesize exec} bind def
99 /c6 {323 459 //.setpagesize exec} bind def
100 % U.S. CAD standard paper sizes
101 /archE {2592 3456 //.setpagesize exec} bind def
102 /archD {1728 2592 //.setpagesize exec} bind def
103 /archC {1296 1728 //.setpagesize exec} bind def
104 /archB {864 1296 //.setpagesize exec} bind def
105 /archA {648 864 //.setpagesize exec} bind def
107 /flsa {612 936 //.setpagesize exec} bind def % U.S. foolscap
108 /flse {612 936 //.setpagesize exec} bind def % European foolscap
109 /halfletter {396 612 //.setpagesize exec} bind def
110 % minimum of a4 and letter (a4 width, letter length)
111 /pa4 {595 792 //.setpagesize exec} bind def
112 % /tabloid {792 1224 //.setpagesize exec} bind def % 11x17 portrait
113 % /csheet {1224 1584 //.setpagesize exec} bind def % ANSI C 17x22
114 % /dsheet {1584 2448 //.setpagesize exec} bind def % ANSI D 22x34
115 % /esheet {2448 3168 //.setpagesize exec} bind def % ANSI E 34x44
118 currentdict /.setpagesize .undef
122 % Define the pagetype values for the known page formats.
123 % The values for all but letter and note are arbitrary.
125 [ /letter /note %do not change this line, needed by 'setpagetype'
129 STRICT { (%END SIZES) .skipeof } if
130 /a0 /a1 /a2 /a5 /a6 /a7 /a8 /a9 /a10
131 /archA /archB /archC /archD /archE
132 /b0 /b1 /b2 /b3 /b4 /b5 /b6
133 /c0 /c1 /c2 /c3 /c4 /c5 /c6
134 /flsa /flse /halfletter
135 /isob0 /isob1 /isob2 /isob3 /isob4 /isob5 /isob6
136 /jisb0 /jisb1 /jisb2 /jisb3 /jisb4 /jisb5 /jisb6
141 %%%%%% The following items were suggested by a user as useful.
143 % Permanent definitions
146 /hardwareiomode 0 def
147 /sethardwareiomode {pop} bind def
148 /softwareiomode 0 def
149 /setsoftwareiomode {pop} bind def
150 /dosysstart false def
151 /setdosysstart {pop} bind def
152 /allowjobreset true def
153 /setallowjobreset {pop} bind def
154 /defaultpaperfamily 0 def
155 /setdefaultpaperfamily {pop} bind def
156 /defaultpapertray 0 def
157 /setdefaultpapertray {pop} bind def
158 /defaulttrayswitch false def
159 /setdefaulttrayswitch {pop} bind def
161 % Tray and format selection
163 /11x17tray {/11x17 .uservar exec} bind def
164 /a3tray {/a3 .uservar exec} bind def
165 /a4tray {/a4 .uservar exec} bind def
166 /a5tray {/a5 .uservar exec} bind def
167 /a6tray {/a6 .uservar exec} bind def
168 /b4tray {/b4 .uservar exec} bind def
169 /b5tray {/b5 .uservar exec} bind def
170 /flsatray {/flsa .uservar exec} bind def
171 /flsetray {/flse .uservar exec} bind def
172 /halflettertray {/halfletter .uservar exec} bind def
173 /ledgertray {/ledger .uservar exec} bind def
174 /legaltray {/legal .uservar exec} bind def
175 /lettertray {/letter .uservar exec} bind def
179 /paperfamily 0 def % 0 is US, 1 is European
181 /setpapertray {statusdict exch /papertray exch put} bind def
182 /trayswitch false def % paperout feeds from another tray
183 % We don't implement the (undocumented by Adobe) papersize 'operator',
184 % because it's very awkward to make it interact properly with all the
185 % different ways of setting the paper size.
186 %/papersize {/letter true} bind def % <name of paper size>, <short-edge-first-p>
187 /appletalktype (LaserWriter) def
189 %%%%%% The following items are defined in the PostScript Language
190 %%%%%% Reference Manual, First Edition, and subsequent 'compatibility'
191 %%%%%% documentation from Adobe.
193 /checkpassword {statusdict begin .password eq end} bind def
194 /defaulttimeouts {statusdict begin .timeouts aload pop end} bind def
196 false (%disk*%) { pop not exit } 8192 string /IODevice resourceforall
198 /diskstatus {10240 2097152 } bind odef % - diskstatus <free> <total> (in 1024 byte pages)
201 /eescratch {pop 0} bind def
202 /idlefonts {statusdict begin mark .idlefonts aload pop end} bind def
205 /manualfeed false def
206 /manualfeedtimeout 60 def
207 /margins {statusdict begin .topmargin .leftmargin end} bind def
208 /pagecount {4711} bind def
209 /pagestackorder {false} bind def
212 /printererror {pop pop} bind def
213 /printername {statusdict /.printername get exch copy} bind def
214 /processcolors /processcolors load def % defined in systemdict
215 /product product def % product is defined in systemdict
216 /revision revision def % revision is defined in systemdict
217 /sccbatch {pop 9600 0} bind def
218 /sccinteractive {pop 9600 0} bind def
219 /setdefaulttimeouts {statusdict begin .timeouts astore pop end} bind def
220 /setdostartpage {statusdict exch /dostartpage exch put} bind def
221 /setduplexmode {mark /Duplex 3 -1 roll currentdevice putdeviceprops} bind def
222 /seteescratch {pop pop} bind def
223 /setidlefonts {] statusdict exch /.idlefonts exch put} bind def
224 /setjobtimeout {statusdict exch /jobtimeout exch put} bind def
227 /.leftmargin exch def /.topmargin exch def
231 % The following compatibility operators are only documented by Adobe in a
232 % supplement to the Red Book.
234 % - pagemargin <offset>
235 % - pageparams <width> <height> <offset> <orientation>
236 % <width> <height> <orientation> setpage -
237 % <offset> setpagemargin -
238 % <width> <height> <offset> <orientation> setpageparams -
240 % width and height are in default units (and if orientation is odd, are
241 % exchanged!). offset is the x margin, also in default units.
242 % Unfortunately, because orientation is relative to the device paper feed,
243 % it does not have a consistent meaning in terms of image orientation.
244 % We follow the convention that ORIENT1 determines the orientation value
245 % that means portait: false means 0, true means 1.
247 /pagemargin { 0 } bind def
249 { currentdevice 1 dict dup /.MediaSize dup put .getdeviceparams
250 exch pop exch pop aload pop 0 ORIENT1 { 1 } { 0 } ifelse
253 { ORIENT1 { 1 } { 0 } ifelse ne {exch} if
254 statusdict /.setpagesize get exec
256 /setpagemargin {pop} bind def % can't do better without setpagedevice
258 { exch pop ORIENT1 { 1 } { 0 } ifelse ne {exch} if
259 statusdict /.setpagesize get exec
263 % The Adobe documentation only defines setpagetype
264 % (a Level 1 operator) as accepting the values 0 and 1,
266 dup .pagetypenames 0 2 getinterval exch get
267 //systemdict /userdict get exch get cvx exec
273 {statusdict exch /.password exch put true}
277 {dup length string copy statusdict exch /.printername exch put} bind def
279 % setresolution is not documented by Adobe, but some applications
280 % use it anyway, without testing whether or not it is present.
282 % <pixels_per_inch> setresolution -
284 % sets the resolution of the device.
287 { mark /HWResolution [ 4 -1 roll dup ] currentdevice putdeviceprops pop
290 /setsccbatch {pop pop pop} bind def
291 /setsccinteractive {pop pop pop} bind def
292 /settumble {pop} bind def
295 %%%%%% End of documented items.
299 4 index 4 index matrix defaultmatrix dtransform
300 abs ceiling cvi exch abs ceiling cvi exch
301 ] currentdevice putdeviceprops pop pop pop
302 initmatrix initclip erasepage
305 /.timeouts [0 60 30] def
310 product setprintername
314 %%%%%% The following documented compatibility "operators" are in systemdict,
315 %%%%%% not in statusdict.
318 .currentglobal true .setglobal
321 /devforall { % <pattern> <proc> <scratch> devforall -
323 1 index currentdevparams
324 /Type .knownget { /FileSystem eq } { false } ifelse
325 { exec } { pop pop } ifelse
326 } /exec load 3 packedarray cvx exch
327 (*) 3 1 roll /IODevice resourceforall
330 /devstatus { % <(%disk*%)> devstatus <searchable> <writable>
331 % <hasNames> <mounted> <removable> <searchOrder>
332 % <freePages> <size> true
333 % <string> devstatus false
335 dup 0 5 getinterval (%disk) eq {
336 dup /IODevice resourcestatus {
337 pop pop dup currentdevparams
339 exch dup /Writeable get
340 exch dup /HasNames get
341 exch dup /Mounted get
342 exch dup /Removable get
343 exch dup /SearchOrder get
345 exch /LogicalSize get
358 .setglobal end % systemdict
360 % The following contents of serverdict are a complete guess,
361 % based on some observed LaserWriter boilerplate.
365 /execjob { } bind def
366 % The Red Book implies that something like the following is
367 % an appropriate definition of exitserver.
368 /exitserver { clear stop } bind def
369 % However, this interacts badly with our standard error handler,
370 % so we override it with the following less appropriate definition.
371 /exitserver { 0 ne { clear cleardictstack } if } bind def
372 /setrealdevice { } bind def