]> git.ipfire.org Git - thirdparty/cups.git/blob - examples/testfile.ps
Changelog
[thirdparty/cups.git] / examples / testfile.ps
1 %!PS-Adobe-3.0
2 %%BoundingBox: 0 0 612 792
3 %%Pages: 1
4 %%LanguageLevel: 1
5 %%DocumentData: Clean7Bit
6 %%DocumentSuppliedResources: procset testprint/2.3
7 %%DocumentNeededResources: font Helvetica Helvetica-Bold Times-Roman
8 %%Creator: Michael Sweet, Apple Inc.
9 %%CreationDate: D:20070606214000+0500
10 %%Title: Test Page
11 %%EndComments
12 %%BeginProlog
13 %%BeginResource procset testprint 2.3 0
14 %
15 % PostScript test page for CUPS.
16 %
17 % Copyright (c) 2007-2011 Apple Inc.
18 % Copyright (c) 1993-2007 Easy Software Products
19 %
20 % Licensed under Apache License v2.0. See the file "LICENSE" for more
21 % information.
22 %
23 /SEXTANT { % Draw a color wheel sextant...
24 % (name) white radius r g b SEXTANT -
25 % Loop through 100 shades...
26 0 0.010101 0.98 {
27 % Set the color...
28 dup 0.75 le { % Get "white" value
29 % Start from black
30 dup 0.75 div % val2 = val / 0.75
31
32 0 index 5 index mul % R = R * val2
33 1 index 5 index mul % G = G * val2
34 2 index 5 index mul % B = B * val2
35
36 4 -1 roll pop % Discard val2
37 } {
38 % Fade to white
39 dup neg 1 add 4 mul % val2 = (1 - val) * 4
40
41 0 index 5 index mul % R = R * val2
42 1 index neg 1 add add % + (1 - val2)
43 1 index 5 index mul % G = G * val2
44 2 index neg 1 add add % + (1 - val2)
45 2 index 5 index mul % B = B * val2
46 3 index neg 1 add add % + (1 - val2)
47
48 4 -1 roll pop % Discard val2
49 } ifelse
50 setrgbcolor % Set the color...
51
52 % Draw the polygon...
53 newpath % Start a new path...
54 dup 5 index mul % r1 = radius * val
55 0 0 3 -1 roll 0 60 arc % Draw the inner arc
56
57 dup 0.010101 add 5 index mul% r2 = (radius + 0.010101) * val
58 0 0 3 -1 roll 60 0 arcn % Draw the outer arc
59
60 closepath % Close the path
61 fill % Fill it...
62
63 pop % Pop value...
64 } for
65
66 % Draw a line around the polygons...
67 pop pop pop dup % Pop R, G, B, start
68 0 setgray % Black
69 newpath
70 0 0 moveto % Center
71 0 0 3 -1 roll 0 60 arc % Arc around octant
72 closepath % Back to center
73 stroke % Stroke it...
74
75 % Draw the label...
76 dup % Save radius
77 dup 30 cos mul % X = radius * cos(30)
78 exch 30 sin mul % Y = radius * sin(30)
79 moveto % Position label
80
81 gsave
82 30 rotate % Rotate label
83 dup 0.05 mul % Offset to the right
84 exch -0.05 mul % and down...
85 rmoveto % Offset label
86 show % Show label
87 grestore
88 } bind def
89 /CENTER { % Draw centered text
90 % (name) CENTER -
91 dup stringwidth pop % Get the width of the string
92 0.5 mul neg 0 rmoveto % Shift left 1/2 of the distance
93 show % Show the string
94 } bind def
95 /RIGHT { % Draw right-justified text
96 % (name) RIGHT -
97 dup stringwidth pop % Get the width of the string
98 neg 0 rmoveto % Shift left the entire distance
99 show % Show the string
100 } bind def
101 /NUMBER { % Draw a number
102 % power n NUMBER -
103 1 index 1 eq { % power == 1?
104 round cvi exch pop % Convert "n" to integer
105 } {
106 1 index mul round exch div % Truncate extra decimal places
107 } ifelse
108 100 string cvs show % Convert to a string and show it...
109 } bind def
110 /CUPSLOGO { % Draw the CUPS logo
111 % height CUPSLOGO
112 % Start with a big C...
113 /Helvetica findfont 1 index scalefont setfont
114 0 setgray
115 0 0 moveto
116 (C) show
117
118 % Then "UNIX Printing System" much smaller...
119 /Helvetica-Bold findfont 1 index 9 div scalefont setfont
120 0.25 mul
121 dup dup 2.0 mul moveto
122 (UNIX) show
123 dup dup 1.6 mul moveto
124 (Printing) show
125 dup 1.2 mul moveto
126 (System) show
127 } bind def
128 %%EndResource
129 %%EndProlog
130 %%Page: 1 1
131 gsave
132
133 % Determine the imageable area and device resolution...
134 initclip newpath clippath pathbbox % Get bounding rectangle
135 72 div /pageTop exch def % Get top margin in inches
136 72 div /pageRight exch def % Get right margin in inches
137 72 div /pageBottom exch def % Get bottom margin in inches
138 72 div /pageLeft exch def % Get left margin in inches
139
140 4 setlinewidth % Draw wide lines
141 0 setgray closepath stroke % Draw a clipping rectangle
142
143 /pageWidth pageRight pageLeft sub def % pageWidth = pageRight - pageLeft
144 /pageHeight pageTop pageBottom sub def% pageHeight = pageTop - pageBottom
145
146 72 72 dtransform % Get device resolution per inch
147 /yResolution exch abs def % yResolution = abs(yres)
148 /xResolution exch abs def % xResolution = abs(xres)
149
150 % Figure out the sizes of things...
151 /wheelSize % size of wheels
152 pageWidth pageHeight lt
153 { pageWidth 9 mul }
154 { pageHeight 7 mul }
155 ifelse def
156
157 % Create fonts...
158 /bigFont /Helvetica-Bold findfont % bigFont = Helvetica-Bold
159 pageHeight 3 mul scalefont def % size = pageHeight * 3 (nominally 33)
160
161 /mediumFont /Helvetica findfont % mediumFont = Helvetica
162 pageHeight 1.5 mul scalefont def % size = pageHeight * 1.5 (nominally 16.5)
163
164 /smallFont /Times-Roman findfont % smallFont = Times-Roman
165 pageHeight scalefont def % size = pageHeight (nominally 11)
166
167 % Draw rulers along the edges...
168 /CENTIMETER 72 2.54 div def
169 /MILLIMETER 72 25.4 div def
170
171 /Times-Roman findfont % Font for ruler numbers
172 11 scalefont setfont % 11 points
173
174 gsave % Left side inches
175 pageLeft 72 mul 0 translate % Offset left edge
176
177 1 setlinewidth % Draw normal lines
178 72 72 pageTop 72 mul { % Height inches
179 dup dup
180 0 exch moveto 24 0 rlineto stroke % Draw tic mark
181 24 exch pageHeight sub moveto % Draw number
182 72 div cvi 10 string cvs RIGHT
183 } for
184
185 0.5 setlinewidth % Draw thin lines
186 18 18 pageTop 72 mul { % 1/4 inches
187 0 exch moveto 15 0 rlineto stroke % Draw tic mark
188 } for
189
190 9 9 pageTop 72 mul { % 1/8 inches
191 0 exch moveto 6 0 rlineto stroke % Draw tic mark
192 } for
193 grestore
194
195 gsave % Bottom inches
196 0 pageBottom 72 mul translate % Offset bottom edge
197
198 1 setlinewidth % Draw normal lines
199 72 72 pageRight 72 mul { % Width inches
200 dup dup
201 0 moveto 0 24 rlineto stroke % Draw tic mark
202 3 add 27 pageHeight sub moveto % Draw number
203 72 div cvi 10 string cvs show
204 } for
205
206 0.5 setlinewidth % Draw thin lines
207 18 18 pageRight 72 mul { % 1/4 inches
208 0 moveto 0 15 rlineto stroke % Draw tic mark
209 } for
210
211 9 9 pageRight 72 mul { % 1/8 inches
212 0 moveto 0 6 rlineto stroke % Draw tic mark
213 } for
214 grestore
215
216 gsave % Right side centimeters
217 pageRight 72 mul 0 translate % Offset right edge
218
219 1 setlinewidth % Draw normal lines
220 CENTIMETER CENTIMETER
221 pageTop 72 mul { % Height centimeters
222 0 exch moveto -24 0 rlineto stroke% Draw tic mark
223 } for
224 1 1 pageTop 2.54 mul { % Height labels
225 dup
226 -24 exch CENTIMETER mul
227 pageHeight sub moveto % Draw number
228 cvi 10 string cvs show
229 } for
230
231 0.5 setlinewidth % Draw thin lines
232 0 0.5 CENTIMETER mul
233 pageTop 72 mul { % 1/2 centimeters
234 0 exch moveto -15 0 rlineto stroke% Draw tic mark
235 } for
236 0 MILLIMETER pageTop 72 mul { % Millimeters
237 0 exch moveto -6 0 rlineto stroke % Draw tic mark
238 } for
239 grestore
240
241 gsave % Top centimeters
242 0 pageTop 72 mul translate % Offset top edge
243
244 1 setlinewidth % Draw normal lines
245 CENTIMETER CENTIMETER
246 pageRight 72 mul { % Width centimeters
247 0 moveto 0 -24 rlineto stroke % Draw tic mark
248 } for
249 1 1 pageRight 2.54 mul { % Width labels
250 dup
251 CENTIMETER mul 3 add -24 moveto % Draw number
252 cvi 10 string cvs show
253 } for
254
255 0.5 setlinewidth % Draw thin lines
256 0 0.5 CENTIMETER mul
257 pageRight 72 mul { % 1/2 centimeters
258 0 moveto 0 -15 rlineto stroke % Draw tic mark
259 } for
260 0 MILLIMETER pageRight 72 mul { % Millimeters
261 0 moveto 0 -6 rlineto stroke % Draw tic mark
262 } for
263 grestore
264
265 % Offset page to account for lower-left margin...
266 pageLeft 72 mul
267 pageBottom 72 mul
268 translate
269
270 % Set text font and color...
271 mediumFont setfont % Font
272 0 setgray % Color
273 1 setlinewidth % Draw normal lines
274
275 % Draw the color wheel...
276 gsave
277 % Position the wheel on the left side...
278 pageWidth 18 mul % x = pageWidth * 1/4 * 72
279 pageHeight 54 mul % y = pageHeight * 3/4 * 72
280 translate
281
282 % Size the wheel...
283 wheelSize
284
285 % Draw the colors...
286 dup (C) 3 -1 roll 0 1 1 SEXTANT 60 rotate
287 dup (M) 3 -1 roll 1 0 1 SEXTANT 60 rotate
288 dup (Y) 3 -1 roll 1 1 0 SEXTANT 60 rotate
289 dup (R) 3 -1 roll 1 0 0 SEXTANT 60 rotate
290 dup (G) 3 -1 roll 0 1 0 SEXTANT 60 rotate
291 dup (B) 3 -1 roll 0 0 1 SEXTANT 60 rotate
292
293 pop
294 grestore
295
296 % Label the color wheel...
297 pageWidth 18 mul % x = pageWidth * 1/4 * 72
298 pageHeight 43 mul % y = pageHeight * 19/32 * 72
299 moveto % Position the text
300 (Color Wheel) CENTER % Show the text centered
301
302 % Draw the gray ramp...
303 gsave
304 % Position the gray ramp in the center...
305 pageWidth 36 mul % x = pageWidth * 1/2 * 72
306 pageHeight 54 mul % y = pageHeight * 3/4 * 72
307 wheelSize sub % - wheelSize
308 translate
309
310 % Loop through 100 shades...
311 0 0.010101 0.98 {
312 % Set the color...
313 dup setgray % Set the grayscale...
314
315 % Draw the polygon...
316 newpath % Start a new path...
317
318 wheelSize -0.2 mul % X = -wheelSize / 5
319 1 index 2 mul wheelSize mul % Y = val * 2 * wheelSize
320 moveto % Move there...
321
322 wheelSize 0.4 mul 0 rlineto % Right side...
323
324 wheelSize 0.2 mul % X = wheelSize / 5
325 1 index 0.010101 add 2 mul wheelSize mul
326 % Y = (val + 0.010101) * 2 * wheelSize
327 lineto % Move there...
328
329 wheelSize -0.4 mul 0 rlineto % Left side...
330
331 closepath % Close the path
332 fill % Fill it...
333
334 pop % Pop value...
335 } for
336
337 0 setgray % Black
338
339 newpath % Start a new path
340 wheelSize -0.2 mul 0 moveto % Bottom left
341 wheelSize 0.4 mul 0 rlineto % Bottom right
342 0 wheelSize 2 mul rlineto % Upper right
343 wheelSize -0.4 mul 0 rlineto % Upper left
344 closepath % Close the path
345 stroke % Stroke it...
346
347 0 wheelSize -0.2 mul moveto % Center bottom for label
348 (K) CENTER % Center K at bottom
349
350 0 wheelSize 2.05 mul moveto % Center top for label
351 (W) CENTER % Center W at top
352 grestore
353
354 % Label the gray ramp...
355 pageWidth 36 mul % x = pageWidth * 1/2 * 72
356 pageHeight 43 mul % y = pageHeight * 19/32 * 72
357 moveto % Position the text
358 (Gray Ramp) CENTER % Show the text centered
359
360
361 % Draw radial lines...
362 gsave
363 0 setlinewidth % 1 pixel lines
364
365 % Position the lines on the left side...
366 pageWidth 54 mul % x = pageWidth * 3/4 * 72
367 pageHeight 54 mul % y = pageHeight * 3/4 * 72
368 translate
369
370 % Size the wheel...
371 wheelSize
372
373 % Loop at 1 degree increments
374 0 1 359 {
375 pop % Discard angle - not used
376 0 0 moveto % Start line at the center
377 dup 0 lineto % Draw to the radius
378 1 rotate % Rotate 1 degree
379 } for
380
381 pop % Discard radius - not needed anymore
382 stroke % Draw lines...
383
384 grestore
385
386 % Label the lines...
387 pageWidth 54 mul % x = pageWidth * 3/4 * 72
388 pageHeight 43 mul % y = pageHeight * 19/32 * 72
389 moveto % Position the text
390 (1 Degree Radial Lines) CENTER % Show the text centered
391
392 % Imageable area...
393 pageHeight 15 mul % Height of imageable area
394
395 pageWidth 4.5 mul % x = pageWidth * 1/16 * 72
396 pageHeight 35.5 mul % y = pageHeight * 1/2 * 72
397 2 index sub % y -= height
398 pageWidth 28 mul % width = pageWidth * 1/4 * 72
399 3 index % height
400 0.5 setgray rectfill % Draw a shadow
401
402 pageWidth 4 mul % x = pageWidth * 1/16 * 72
403 pageHeight 36 mul % y = pageHeight * 1/2 * 72
404 2 index sub % y -= height
405 pageWidth 28 mul % width = pageWidth * 3/8 * 72
406 3 index % height
407 4 copy 1 setgray rectfill % Clear the box to white
408 0 setgray rectstroke % Draw a black box around it...
409
410 pop % Discard height
411
412 % Label the imageable area...
413 pageWidth 4 mul % x = pageWidth * 1/16 * 72
414 pageHeight 37 mul % y = pageHeight * 1/2 * 72
415 moveto % Position the text
416 mediumFont setfont % Font
417 (Imageable Area) show % Show the text
418
419 smallFont setfont % Font
420 pageWidth 14 mul % x = pageWidth * 3/16 * 72
421 pageHeight 36 mul % y = pageWidth * 1/2 * 72
422 pageHeight -2 mul add % y -= 2 * smallFont height
423
424 % Page Size inches
425 2 copy moveto % Move to x & y
426 (Page Size: ) RIGHT % Label
427 100 pageWidth NUMBER % pageWidth
428 (x) show % "x"
429 100 pageHeight NUMBER % pageHeight
430 (in) show % "in"
431
432 % Page Size millimeters
433 pageHeight sub % Move down...
434
435 2 copy moveto % Move to x & y
436 10 pageWidth 25.4 mul NUMBER % pageWidth
437 (x) show % "x"
438 10 pageHeight 25.4 mul NUMBER % pageHeight
439 (mm) show % "mm"
440
441 % Lower-left inches
442 pageHeight 2 mul sub % Move down...
443
444 2 copy moveto % Move to x & y
445 (Lower-Left: ) RIGHT % Label
446 100 pageLeft NUMBER % pageLeft
447 (x) show % "x"
448 100 pageBottom NUMBER % pageBottom
449 (in) show % "in"
450
451 % Lower-left millimeters
452 pageHeight sub % Move down...
453
454 2 copy moveto % Move to x & y
455 10 pageLeft 25.4 mul NUMBER % pageLeft
456 (x) show % "x"
457 10 pageBottom 25.4 mul NUMBER % pageBottom
458 (mm) show % "mm"
459
460 % Upper-right inches
461 pageHeight 2 mul sub % Move down...
462
463 2 copy moveto % Move to x & y
464 (Upper-Right: ) RIGHT % Label
465 100 pageRight NUMBER % pageRight
466 (x) show % "x"
467 100 pageTop NUMBER % pageTop
468 (in) show % "in"
469
470 % Upper-right millimeters
471 pageHeight sub % Move down...
472
473 2 copy moveto % Move to x & y
474 10 pageRight 25.4 mul NUMBER % pageRight
475 (x) show % "x"
476 10 pageTop 25.4 mul NUMBER % pageTop
477 (mm) show % "mm"
478
479 % Resolution dots-per-inch
480 pageHeight 2 mul sub % Move down...
481
482 2 copy moveto % Move to x & y
483 (Resolution: ) RIGHT % Label
484 1 xResolution NUMBER % xResolution
485 (x) show % "x"
486 1 yResolution NUMBER % yResolution
487 (dpi) show % "dpi"
488
489 % Resolution dots-per-meter
490 pageHeight sub % Move down...
491
492 moveto % Move to x & y
493 1 xResolution 39.27 mul NUMBER % xResolution
494 (x) show % "x"
495 1 yResolution 39.27 mul NUMBER % yResolution
496 (dpm) show % "dpm"
497
498 % Interpreter Information...
499 pageHeight 15 mul % Height of interpreter information
500
501 pageWidth 40.5 mul % x = pageWidth * 9/16 * 72
502 pageHeight 35.5 mul % y = pageHeight * 1/2 * 72
503 2 index sub % y -= height
504 pageWidth 28 mul % width = pageWidth * 1/4 * 72
505 3 index % height
506 0.5 setgray rectfill % Draw a shadow
507
508 pageWidth 40 mul % x = pageWidth * 9/16 * 72
509 pageHeight 36 mul % y = pageHeight * 1/2 * 72
510 2 index sub % y -= height
511 pageWidth 28 mul % width = pageWidth * 3/8 * 72
512 3 index % height
513 4 copy 1 setgray rectfill % Clear the box to white
514 0 setgray rectstroke % Draw a black box around it...
515
516 pop % Discard height
517
518 % Label the interpreter info...
519 pageWidth 40 mul % x = pageWidth * 9/16 * 72
520 pageHeight 37 mul % y = pageHeight * 1/2 * 72
521 moveto % Position the text
522 mediumFont setfont % Font
523 (Interpreter Information) show % Show the text
524
525 smallFont setfont % Font
526 pageWidth 49 mul % x = pageWidth * 11/16 * 72
527 pageHeight 36 mul % y = pageWidth * 1/2 * 72
528 pageHeight 2 mul sub % y -= 2 * smallFont height
529
530 % Language level
531 2 copy moveto % Move to x & y
532 (PostScript: ) RIGHT % Label
533 (Level ) show % "Level "
534 1 languagelevel NUMBER % Language level
535
536 % Version
537 pageHeight 2 mul sub % Move down...
538 2 copy moveto % Move to x & y
539 (Version: ) RIGHT % Label
540 version show % Version
541 ( \() show % " ("
542 1 revision NUMBER % Revision
543 (\)) show % ")"
544
545 % Product
546 pageHeight 2 mul sub % Move down...
547 2 copy moveto % Move to x & y
548 (Product: ) RIGHT % Label
549 product show % Product name
550
551 % Serial Number
552 pageHeight 2 mul sub % Move down...
553 moveto % Move to x & y
554 (Serial #: ) RIGHT % Label
555 1 serialnumber NUMBER % S/N
556
557 % Draw the label at the top...
558 pageWidth 36 mul % Center of page
559 pageHeight 66 mul % Top of page (11/12ths)
560 moveto % Position text
561 bigFont setfont % Font
562 (Printer Test Page) CENTER % Show text centered
563
564 % Draw the copyright notice at the bottom...
565 pageWidth 17 mul % Center of page
566 pageHeight 10 mul % Bottom of page
567 moveto % Position text
568 (Printed Using CUPS v2.3.x) show
569
570 pageWidth 17 mul % Left side of page
571 pageHeight 8 mul % Move down...
572 2 copy moveto % Position text
573 smallFont setfont % Font
574 (Copyright 2007-2018 Apple Inc., All Rights Reserved. CUPS and the CUPS logo are trademarks) show
575 pageHeight 2 add sub % Move down...
576 2 copy moveto % Position text
577 (of Apple Inc., One Apple Park Way, Cupertino, CA 95014, USA.) show
578 pageHeight 2 mul 4 add sub % Move down...
579 moveto % Position text
580 (Need help? Contact your operating system vendor or visit "http://www.cups.org/".) show
581
582 % Then the CUPS logo....
583 gsave
584 pageWidth 4 mul
585 pageHeight 4 mul
586 translate
587 pageWidth 15 mul CUPSLOGO
588 grestore
589
590 % Show the page...
591 grestore
592 showpage
593 %%EOF