summaryrefslogtreecommitdiff
path: root/dviware/psprint/unix/lino_header.ps
blob: 44aaeef32054a19a47b1d2609c25330916f5e2f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
% This file is sent at the start of each Linotronic job.
% It defines @bannerpage, @footerpage and a PostScript error handler.
% It also defines page sizes and orientations, margin, and cutmark procedure.

statusdict begin /waittimeout 300 def end   % wait 5 minutes

/@bannerpage                     % called below
{ initgraphics
  statusdict begin
     842 72 0 1 setpageparams    % width height margin orientation
  end
  25 0 translate                 % move origin to the right
  /vpos 55 def                   % initial vertical pos
  0 vpos moveto                  % start near top left corner
  /newline
     { /vpos vpos 15 sub def     % decrease vertical pos by 15pt
       0 vpos moveto             % move to start of new line
     } def
  /newline2
     { /vpos vpos 10 sub def     % decrease vertical pos by 10pt
       0 vpos moveto             % move to start of new line
     } def
  /Courier findfont              % Courier typewriter font
  9 scalefont setfont            % at 9pt
  (****************************************************************************\
**********************************************************) show newline2
  /Courier findfont              % Courier typewriter font
  15 scalefont setfont           % at 15pt
  @USER show newline             % user name and file spec
  /Courier findfont              % Courier typewriter font
  9 scalefont setfont            % at 9pt
  @DATE show newline2
  @NOTE show newline2
  (----------------------------------------------------------------------------\
----------------------------------------------------------) show
  /#copies 1 def                 % print only 1 copy of banner page
  systemdict /showpage get exec
} def

/@footerpage                     % called at end of job or after error
{ initgraphics
  statusdict begin
     842 72 0 1 setpageparams    % width height margin orientation
  end
  25 0 translate                 % move origin to the right
  /vpos 55 def                   % initial vertical pos
  0 vpos moveto                  % start near top left corner
  /newline
     { /vpos vpos 15 sub def     % decrease vertical pos by 15pt
       0 vpos moveto             % move to start of new line
     } def
  /newline2
     { /vpos vpos 10 sub def     % decrease vertical pos by 10pt
       0 vpos moveto             % move to start of new line
     } def
  /Courier findfont              % Courier typewriter font
  9 scalefont setfont            % at 9pt
  (----------------------------------------------------------------------------\
----------------------------------------------------------) show newline2
  /Courier findfont              % Courier typewriter font
  15 scalefont setfont           % at 15pt
  @USER show newline             % user name and file spec
  /Courier findfont              % Courier typewriter font
  9 scalefont setfont            % at 9pt
  @DATE show newline2
  (PAGE COUNT: ) show
  statusdict begin
     pagecount                   % current pagecount
  end
  @oldpagecount                  % pagecount saved in banner.ps
  sub (          ) cvs
  show newline2                  % show pages printed
  (****************************************************************************\
**********************************************************) show
  /#copies 1 def                 % print only 1 copy of footer page
  systemdict /showpage get exec
} def

% Redefine the error handler in errordict to show a suitable error message.

/@errpage 64 dict def
@errpage begin
/prnt
{ dup type/stringtype ne{=string cvs}if dup length 6 mul/tx exch def/ty 10 def
  currentpoint/toy exch def/tox exch def 1 setgray newpath
  tox toy 2 sub moveto 0 ty rlineto tx 0 rlineto 0 ty neg rlineto
  closepath fill tox toy moveto 0 setgray show
} bind def
/nl {currentpoint exch pop lmargin exch moveto 0 -11 rmoveto} def
/== {/cp 0 def typeprint nl} def
/typeprint
{ dup type dup currentdict exch known
  {exec}{unknowntype}ifelse
} readonly def
/lmargin 72 def
/rmargin 72 def
/tprint
{ dup length cp add rmargin gt{nl/cp 0 def}if
  dup length cp add/cp exch def prnt
} readonly def
/cvsprint     {=string cvs tprint( )tprint} readonly def
/unknowntype  {exch pop cvlit(??)tprint cvsprint} readonly def
/integertype  {cvsprint} readonly def
/realtype     {cvsprint} readonly def
/booleantype  {cvsprint} readonly def
/operatortype {(//)tprint cvsprint} readonly def
/marktype     {pop(-mark- )tprint} readonly def
/dicttype     {pop(-dictionary- )tprint} readonly def
/nulltype     {pop(-null- )tprint} readonly def
/filetype     {pop(-filestream- )tprint} readonly def
/savetype     {pop(-savelevel- )tprint} readonly def
/fonttype     {pop(-fontid- )tprint} readonly def
/nametype     {dup xcheck not{(/)tprint}if cvsprint} readonly def
/stringtype
{ dup rcheck{(\()tprint tprint(\))tprint}{pop(-string- )tprint}ifelse
} readonly def
/arraytype
{ dup rcheck{dup xcheck
  {({)tprint{typeprint}forall(})tprint}
  {([)tprint{typeprint}forall(])tprint}ifelse}{pop(-array- )tprint}ifelse
} readonly def
/packedarraytype
{ dup rcheck{dup xcheck
  {({)tprint{typeprint}forall(})tprint}
  {([)tprint{typeprint}forall(])tprint}ifelse}{pop(-packedarray- )tprint}ifelse
} readonly def
/courier /Courier findfont 10 scalefont def
/@oldhandleerror errordict /handleerror get def   % save current error handler
end
% of @errpage

errordict /handleerror                            % redefine error handler
{ systemdict begin $error begin @errpage begin
  newerror
  { /newerror false store
    vmstatus pop pop 0 ne { grestoreall } if
    initgraphics
    newpath clippath pathbbox                     % push LLx LLy URx URy
    lmargin exch 360 sub moveto                   % subtract 5" from URy
    pop pop pop                                   % remove URx LLy LLx
    courier setfont
    (POSTSCRIPT ERROR: ) prnt errorname prnt nl
    (OFFENDING COMMAND: ) prnt /command load prnt nl
    $error /ostack known
    { (OPERAND STACK:) prnt nl
      $error /ostack get aload length {==} repeat
    } if
    /#copies 1 store                              % print only one error page
    systemdict /showpage get exec
    userdict begin @footerpage end                % then print footer page
    /newerror true store
    /@oldhandleerror load end end end exec }
  { end end end }
  ifelse
} dup 0 systemdict put dup 4 @errpage put bind readonly put

@bannerpage                                       % print the banner page

/@oldpagecount                                    % used in @footerpage
   statusdict begin pagecount end
def

% margin is offset (in pts) from paper edge.
% psprint must make sure that one of the following page setups is called.
% The built-in page setups are available in version 42.5 but not 38.0.

/A3Lsetup
{ /margin 0 def                % margin + width must be <= 842 = 11.7in
  statusdict begin
     margin setpagemargin
  end
  a3                           % built-in procedure in userdict
} def

/A4Psetup
{ /margin 0 def                % margin + width must be <= 842 = 11.7in
  statusdict begin
     margin setpagemargin
  end
  A4                           % built-in procedure in userdict
} def

/A4Lsetup
{ /margin 25 def
  statusdict begin
     margin setpagemargin
  end
  a4                           % built-in procedure in userdict
} def

/A5Psetup
{ /margin 25 def
  statusdict begin
     margin setpagemargin
  end
  A5                           % built-in procedure in userdict
} def

/A5Lsetup
{ /margin 25 def
  statusdict begin
     margin setpagemargin
  end
  a5                           % built-in procedure in userdict
} def

/B5Psetup
{ /margin 25 def
  statusdict begin
     margin setpagemargin
  end
  B5                           % built-in procedure in userdict
} def

/B5Lsetup
{ /margin 25 def
  statusdict begin
     margin setpagemargin
  end
  b5                           % built-in procedure in userdict
} def

/cornercuts
{ % draw short lines at corners of page image area
  initgraphics
  newpath clippath pathbbox       % push LLx LLy URx URy
     /URy exch def
     /URx exch def
     % don't use LLx LLy because they don't allow for margin setting
     pop pop
  newpath                         % remove clipping path
     % line length = 10pt
     URx URy moveto   -10 0 rlineto
     URx URy moveto   0 -10 rlineto
     0   0   moveto   10 0  rlineto
     0   0   moveto   0 10  rlineto
     0   URy moveto   10 0  rlineto
     0   URy moveto   0 -10 rlineto
     URx 0   moveto   -10 0 rlineto
     URx 0   moveto   0 10  rlineto
     0.2 setlinewidth
  stroke
} def

% psprint will override this default if user asks for -nocut:

/@cutmarks { cornercuts } def

% Redefine userdict showpage to first call @cutmarks, then showpage
% from systemdict, then a thin blank page to separate job pages:

/showpage
{ @cutmarks                                % draw any cut marks
  systemdict /showpage get exec            % show current page
  statusdict begin pageparams end          % get width height margin orientation
  /oldorientation exch def
  /oldmargin exch def
  /oldheight exch def
  /oldwidth exch def                       % save current page setups
  /old#copies #copies def                  % save current #copies
  /#copies 1 def                           % only print 1 gap page
  statusdict begin
     842 18 0 1 setpageparams              % 18pt = .25" gap
  end
  systemdict /showpage get exec            % show gap page
  /@oldpagecount @oldpagecount 1 add def   % increment @oldpagecount
  oldwidth
  oldheight
  oldmargin
  oldorientation
  statusdict begin setpageparams end       % restore saved page setup
  /#copies old#copies def                  % restore saved #copies
} def