3 %%Title: Alignment testpage for Ghostscript
4 %%Creator: Dieter Stueken (<EMAIL: PROTECTED>)
6 % Source: http://www.geocrawler.com/archives/3/378/1997/1/50/2064509/
8 /rectdraw % <x0> <y0> <x1> <y1> rectdraw -
9 { exch 4 -1 roll exch 2 array astore {0 moveto 0 PH rlineto stroke} forall
10 2 array astore {0 exch moveto PW 0 rlineto stroke} forall
13 /arrow % <ang> <x0> <y0> arrow
14 { gsave translate rotate
15 0 0 moveto 20 60 lineto -20 60 lineto closepath stroke
16 0 0 moveto 0 80 lineto stroke
20 /triangle { % len ang x y
21 gsave translate dup rotate exch
25 dup 0.98 mul dup 10 div lineto
27 gsave 0.65 setgray fill grestore stroke
30 gsave 0 -12 rmoveto 0 24 rlineto stroke grestore
31 gsave 0 24 rmoveto 10 div 2 index neg rotate
32 cvi =string cvs -6 -4 rmoveto show grestore
38 gsave 0 -6 rmoveto 0 12 rlineto stroke grestore
45 /round {dup 3 1 roll mul cvi exch div} def
47 /Show { % print value or unfold array
48 dup type /realtype eq {100 round} if
51 {dup type /arraytype eq
52 { ([ ) show {Show} forall ( ]) show}
53 {=string cvs show ( ) show}
58 /Pval { % key val, move down 1 line
60 gsave Show (:) show grestore
68 { currentfile S readline pop dup (%END) eq { pop exit } if
69 gsave show grestore 0 -12 rmoveto
73 /.knownget { 2 copy known { get true } { pop pop false } ifelse } bind def
78 % you may try different settings here, but start with default settings first
80 % /.HWMargins [8.5 38.0 10.5 12.5]
102 /.MarginsHWResolution
106 ] { currentpagedevice 1 index
107 .knownget not {(-undefined-)} if Pval
114 Let the distance in inches from the left edge of the page to the
115 vertical line be H, and from the bottom edge to the horizontal line
116 be V. You may define the alignment of your page to the paper by
118 << /Margins [x y] >> setpagedevice
123 /res currentpagedevice /.MarginsHWResolution .knownget not {600} if def
124 ( x = (1 - H) * ) show res 0 get =string cvs show
125 (, y = (V - 1) * ) show res 1 get =string cvs show
126 grestore 0 -12 rmoveto
130 If set correctly the drawn arrows should extend into the
131 papers corners (not the clipping corners). After archieving
132 that, you may continue with the clipping edges.
134 The clipping edges may be set by
136 << /.HWMargins [ml mb mr mt] >> setpagedevice
138 where [ml mb mr mt] are the distances of the clipped edges of
139 your graphics relative to the papers edges (left bottom right top)
140 measured in 1/72 inches. The wedge shaped rules may be used to
141 define these values very accurately as its intersections are in
142 1/72 inches. Take the value at the cutoff point from the scale to
143 the next clockwise edge.
145 Start setting the margin values to all zero to see the natural hardware
146 clipping of your printer. You should then define the margins just as big
147 enough to keep the defined margins within your printers real hardware
148 clipping. This is archieved if you can see the thin line drawn all around
149 your defined margin. In addition the thin drawn arrows are just touching
150 the margin and should be totally visible.
152 When you put this settings into your inititializing file "gs_init.ps"
153 you may want to apply this setting to a specific printer device only.
154 Here is an example of a printer specific setup:
157 /ljet4 << % make entries for some device
158 /.HWMargins [16.0 13.2 13.0 11.1]
161 /ljet2p << % and for an other devices, too
162 /.HWMargins [14.4 6.8 14.5 17.5]
165 >> currentpagedevice /OutputDevice get
166 .knownget {setpagedevice} if
170 currentpagedevice /PageSize get aload pop
177 PW 180 PW PH triangle
180 % get clipping values
181 clippath pathbbox newpath
185 1 setlinewidth % 0.65 setgray
194 % draw the alignment lines
196 72 0 moveto 0 CT rlineto stroke
197 0 72 moveto CR 0 rlineto stroke
203 0 200 moveto 71 0 rlineto -24 -12 rlineto 0 24 rlineto 24 -12 rlineto stroke
204 34 206 moveto (H) show
206 144 0 moveto 0 71 rlineto -12 -24 rlineto 24 0 rlineto -12 24 rlineto stroke
207 150 34 moveto (V) show
210 % draw arrows into to the papers corners
214 90 sub dup 0 PH arrow
215 90 sub dup PW PH arrow
216 90 sub dup PW 0 arrow
219 % draw arrows touching the clipping edges
222 180 PW 2 div CT arrow
223 -90 CL PH 2 div arrow