home *** CD-ROM | disk | FTP | other *** search
- %!PS-Adobe
- %
- % Script library.
- %
- % $Id: ScriptLibrary.ps,v 1.2 2000/06/10 22:17:52 sergey Exp $
- %
-
- %--- Parameters
-
- /LastName (${lastName}$) def
- /FirstName (${firstName}$) def
- /Company (${company}$) def
- /Title (${title}$) def
- /Phones [ (${phone1}$) (${phone2}$) (${phone3}$) (${phone4}$) (${phone5}$) ] def
- /PhoneLabels [ (${phoneLabel1}$) (${phoneLabel2}$) (${phoneLabel3}$) (${phoneLabel4}$) (${phoneLabel5}$) ] def
- /Address (${address}$) def
- /City (${city}$) def
- /State (${state}$) def
- /Zip (${zip}$) def
- /Country (${country}$) def
-
- true {
- /FrameHeight ${frameHeight}$ def
- /FrameWidth ${frameWidth}$ def
- /FrameMargin ${frameMargin}$ def
- /ScaleX ${scaleX}$ def
- /ScaleY ${scaleY}$ def
- /OneCopy ${oneCopy}$ def
- } {
- /FrameHeight 150 def
- /FrameWidth 235 def
- /FrameMargin 10 def
- /ScaleX 100 def
- /ScaleY 100 def
- /OneCopy false def
- } ifelse
-
- %--- Utilities
-
- % n -- str
- /itoa { /buff { 20 string } def buff cvs } def
-
- % str -- bool
- /NotEmpty { length 0 ne } def
-
- % llx lly urx ury -- Wx Wy
- /BoxSize {
- /ury exch def /urx exch def /lly exch def /llx exch def
- urx llx sub ury lly sub
- } def
-
- %--- Position
-
- % -- width height
- /PageSize {
- currentpagedevice (PageSize) get
- dup 0 get exch 1 get
- } def
-
- /PageMargin 60 def
- /Left PageMargin def
- /Top { PageSize exch pop PageMargin sub } def
- /X Left def
- /Y Top def
-
- % x y --
- /MoveTo {
- /Y exch def /X exch def
- X Y moveto
- } def
-
- % -- width height ; Width and height of the char in current font
- /CharSize {
- gsave newpath 0 0 moveto
- (0) true charpath pathbbox BoxSize
- newpath grestore
- } def
-
- % -- n ; Distance to next line for current font
- /LineSkip { CharSize exch pop 4 add } def
-
- % --
- /CRLF {
- currentpoint exch pop
- X exch moveto 0 LineSkip neg rmoveto
- } def
-
- % -- ; one line down
- /VSPACE { 0 CharSize exch pop neg rmoveto } def
-
- % -- ; one char right
- /SPACE { CharSize pop 0 rmoveto } def
-
- % -- bool ; check for BOL
- /NotBOL { currentpoint pop X CharSize pop add ge } def
-
- % -- ; CRLF only when line not empty
- /_CRLF { NotBOL { CRLF } if } def
-
- % -- ; SPACE only when line not empty
- /_SPACE { NotBOL { SPACE } if } def
-
- %--- Block operations
-
- % block-proc --
- /DrawBlock {
- { show } exch exec
- stroke
- } def
-
- % block-proc -- width height
- /BlockSize {
- newpath 0 0 MoveTo
- { false charpath } exch exec
- pathbbox BoxSize
- newpath
- } def
-
- %--- Block fonts
-
- /SetNameFont { /Times-Bold findfont 15 scalefont setfont } def
- /SetTitleFont { /Times-Italic findfont 10 scalefont setfont } def
- /SetCompanyFont { /Helvetica-Bold findfont 10 scalefont setfont } def
- /SetAddressFont { /Helvetica findfont 7 scalefont setfont } def
- /SetContactTitleFont { /Courier-Italic findfont 7 scalefont setfont } def
- /SetContactFont { /Helvetica findfont 7 scalefont setfont } def
-
- %--- Blocks
-
- % do-proc --
- /PersonalBlock {
- /do exch def
- SetNameFont VSPACE
- FirstName do _SPACE LastName do _CRLF
- SetTitleFont Title do _CRLF
- SetCompanyFont Company do
- } def
-
- % do-proc --
- /AddressBlock {
- /do exch def
- SetAddressFont VSPACE
- Address do _CRLF
- City do _SPACE State do _SPACE Zip do _CRLF
- Country do
- } def
-
- % title text do-proc --
- /ContactItem {
- /do exch def /text exch def /title exch def
- text NotEmpty {
- SetContactTitleFont title do (: ) do
- SetContactFont text do
- CRLF
- } if
- } def
-
- % do-proc --
- /ContactBlock {
- SetContactFont VSPACE
- 0 1 Phones length 1 sub {
- /i exch def
- PhoneLabels i get Phones i get
- 2 index ContactItem
- } for
- pop
- } def
-
- %--- Drawing
-
- % --
- /DrawFrame {
- % we are in upper-left corner
- FrameWidth 0 rlineto
- 0 FrameHeight neg rlineto
- FrameWidth neg 0 rlineto
- closepath stroke
- } def
-
- % --
- /DrawPersonalInfo {
- PersonalInfoPos MoveTo { PersonalBlock } DrawBlock
- } def
-
- % --
- /DrawContactInfo {
- ContactInfoPos MoveTo { ContactBlock } DrawBlock
- } def
-
- % --
- /DrawAddressInfo {
- AddressInfoPos MoveTo { AddressBlock } DrawBlock
- } def
-
- % --
- /DrawCard {
- DrawPersonalInfo DrawAddressInfo DrawContactInfo
- 0 0 MoveTo DrawFrame
- } def
-
- % --
- /DrawManyCards {
- PageSize
- PageMargin 2 mul sub FrameHeight 2 add div truncate cvi /rows exch def
- PageMargin 2 mul sub FrameWidth 2 add div truncate cvi /cols exch def
-
- rows {
- matrix currentmatrix
- cols {
- DrawCard FrameWidth 2 add 0 translate
- } repeat
- setmatrix
- 0 FrameHeight 2 add neg translate
- } repeat
- } def
-
- %-- main
-
- % --
- /Main {
- clear
- erasepage
- initmatrix
-
- Left Top translate
-
- % scale in persent
- ScaleX 100 div ScaleY 100 div scale
-
- OneCopy { DrawCard } { DrawManyCards } ifelse
- } def
-
-