Here is a sample postscipt file, stored using the filename abc0.ps:
%!PS-Adobe-2.0 /Times-Bold findfont 200 scalefont setfont 100 300 moveto (ABC) show showpage
% vi abc0.ps -- create the file using some editor % ps2pdf abc0.ps abc0.pdf -- convert to PDF, produce error messages % lp -d tub abc0.ps -- print on a Postscript printerOpen a link to this file as: .ps, or as .pdf
Basic Topics (from the Blue Book):
Example of overlapping boxes:
%!PS-Adobe-2.0
/width 25 def
/outline { % print standard border on page
/Times-Bold findfont 15 scalefont setfont
newpath width width moveto
0 792 width 2 mul sub rlineto
612 width 2 mul sub 0 rlineto
0 -792 width 2 mul add rlineto
closepath stroke
275 width 5 add moveto (Bottom of Page) show
275 792 width sub 15 sub moveto (Top of Page) show
} def
/coord {
/Times-Bold findfont 50 scalefont setfont
20 20 moveto (1) show
-50 20 moveto (2) show
-50 -50 moveto (3) show
20 -50 moveto (4) show
3 setlinewidth
newpath 0 60 moveto 0 -60 lineto stroke
newpath 60 0 moveto -60 0 lineto stroke
} def
outline
%%%%%%% only change what comes after this comment %%%%%%
200 200 translate
coord
showpage
The result of this Postscript is:
.ps, or as .pdfNow keeping the same functions outline and coords, try some different instructions at the end and see what happens. In each case try to guess what the result will be first and then see what the result is. (I am leaving off the definition of the function and leaving off the final showpage.)
| Postscript Program | Result |
|---|---|
200 200 translate rotate 90 coord | .ps, or as .pdf |
rotate 90 200 200 translate coord | .ps, or as .pdf |
90 rotate 200 -200 translate -90 rotate coord | .ps, or as .pdf |
200 200 translate 90 rotate 2 2 scale coord | .ps, or as .pdf |
2 2 scale 200 200 translate 90 rotate coord | .ps, or as .pdf |
1 1 30 {
pop % throw away loop variable
300 150 translate
45 rotate
coord
0.75 0.75 scale
} for % just loops 30 times
| .ps, or as .pdf |
%!PS-Adobe-2.0
/path { % path is the outline of the chars ABC
/Times-Bold findfont 200 scalefont setfont
newpath 0 0 moveto (ABC) false charpath
} def
/oneline { % draw one line from the origin
0 0 moveto 450 0 lineto stroke
} def
/lines { % draw 180 lines at 1 degree rotations
180 {1 rotate oneline} repeat
} def
100 300 translate % up to middle of page
3 setlinewidth % thick lines
path stroke % outline the characters
1 setlinewidth % thin lines
path clip % clip to inside of charactes
180 0 translate % to middle of string
lines % draw the lines inside the string
showpage % actually render the page
Open a link to this file as:
.ps, or as .pdfOther complex examples: