blob: e2c57cf3974ee14f3d0f311d39cbedd15a462587 (
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
|
% Prologue for a /two job.
% It assumes *_print.com has defined fspec and dev.
% The following definitions produce two logical pages (80 cols by 60 lines)
% on a single landscaped sheet of A4 paper.
% Both pages have a headline showing fspec and page #.
% Every character after this file (until ^D) will be treated as a printing
% character (or control character) instead of being interpreted as PostScript.
/maxlines 60 def % maximum lines per logical page
/maxchar 80 def % maximum chars per line
/interline -8 def % baseline skip
/Courier findfont % Courier font (fixed-width chars)
7 scalefont setfont % at 7pt
/inch { 72 mul } def % convert inches to big points
/topline { 7.3 inch } def % vertical location of top line (not headline)
/page1pos
{ 0 11.7 inch translate % shift origin up 11.7 inch (= A4 width)
-90 rotate % rotate axes 90deg clockwise
1 inch 0 translate % 1 inch left margin for 1st logical page
0 topline moveto % start of first line
/line 0 def % initialize line counter
/char 0 def % initialize chars/line counter
} bind def
/page2pos
{ 5.1 inch 0 translate % set up left margin for 2nd logical page
0 topline moveto % start of first line
/line maxlines def % in case formfeed occurred in 1st logical page
} bind def
/pagenum 0 def % initialize logical page number
/headline
{ gsave % save current pos and font
/Courier-Bold findfont 10 scalefont setfont % use Courier-Bold at 10pt
0 topline moveto % move to top left corner
0 interline 3 mul neg rmoveto % move up 3 lines
fspec show
% increment page number and show it right justified
/pagenum pagenum 1 add def
/pagestr pagenum 10 string cvs def
charwidth maxchar mul topline moveto % move to top right corner
(p.) stringwidth pop
pagestr stringwidth pop add neg % move left by page # width
interline 3 mul neg % move up 3 lines
rmoveto
(p.) show pagestr show
grestore % restore pos and font
} bind def
/formfeed % start next logical page unless already there
{ line 0 gt
{ line maxlines lt
{ headline page2pos } % 0 < line < maxlines
{ line maxlines gt
line maxlines 2 mul lt and
{ headline showpage page1pos } if % maxlines < line < 2 * maxlines
} ifelse
} if
} bind def
/linefeed
{ /char 0 def % reset chars/line counter
/line line 1 add def % increment line counter
line maxlines eq % if end of 1st page
{ headline % show 1st headline
page2pos } % and start 2nd page
{ line maxlines 2 mul eq % elsif end of 2nd page
{ headline % then show 2nd headline
showpage page1pos } % and show both pages
{ currentpoint pop neg interline rmoveto % else start next line
} ifelse
} ifelse
} bind def
/showchar
{ currentchar 0 thischar put % put thischar into 1-char string
/char char 1 add def % increment chars/line counter
char maxchar le { currentchar show } if % ignore chars > maxchar
} bind def
/eachchar
{ infile read not {exit} if % get next char
/thischar exch def % save it in thischar
thischar 32 ge % thischar >= space?
{ showchar } % if so, show it
{ thischar 10 eq % or does thischar = linefeed?
{ linefeed }
{ thischar 12 eq % or does thischar = formfeed?
{ formfeed }
{ % ignore any other control char
} ifelse
} ifelse
} ifelse
} bind def
(%stdin) (r) file /infile exch def
/currentchar 1 string def
/charwidth ( ) stringwidth pop def % assume fixed-width font
page1pos % start 1st page
/charloop
{ {eachchar} loop
line 0 gt
{ headline showpage } % flush last sheet with only 1st logical page
if
dev (LW) eq { @bannerpage } if % print banner page if LaserWriter
} def
charloop
|