HylaFAX The world's most advanced open source fax server

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: What does this PS code mean ?



On Wed, 19 Mar 1997 12:55:57 GMT, in an article from comp.lang.postscript, you wrote:
) Hi.

) Please could someone tell me what's happening in the following 
) postscript code :-

)         % faxmail prologue file.
)         %
)         /EPSbegin{save gsave 20 20 scale 200 dict begin}def
)         /EPSend{end grestore restore}def

Postscript works using a stack, like an RPN calculator.

First, a symbol, "/EPSbegin" is placed on the stack, then a procedure (enclosed
in brackets) is placed on the stack, then 'def' is executed, which associates
the procedure with the symbol (so, think of this symbol as a function that
can be called later in the postscript program).

The procedure consists of 'save', which saves a copy of the current dictionary
(all the defined symbols) to the dictionary stack. 'gsave' saves the current
graphic state (pen size, color, current transformation matrix, path, etc.) to
the stack. 20 and 20 are placed on the stack and 'scale' pops them both
off and modifyes the current translation matrix so that all subsequent
coordinates have their values multiplied by 20 for x and 20 for y. '200 dict'
preallocates some dictionary space and begin pushes the dictionary onto the
current dictionary stack.

EPSbegin, no doubt, is supposed to be used just before an EPS image, however
the preallocating dictionary space isn't necessary.

Similar goes with EPSend except 'end' pops the dictionary off the stack,
'grestore' restores the last graphics state saved with 'gsave', and 'restore'
restores the last dictionary saved with 'save'.


) It is part of the HylaFAX v4.0 fax software and is the user customizable
) part of the email-to-fax gateway.

) The gateway inserts the contents of the file above before generating
) the %%EndProlog marker.

) I've learnt from the excellent 'First Guide to Postscript' website that
) the "20 20 scale" part is magnifying up the coordinates - the gateway
) generates a "0.5 dup scale" line later on in the file - so the user can
) tweak the size of the image.

) The Guide also implies that '/EPSbegin' and '/EPSend' are procedures, 
) but I can't see where they are used... and the procedures names cannot
) be 'begin' and 'end' because they are reserved words, aren't they ??

) I would like to place my own header and footer in the resulting fax
) image, can I achieve this though this code ? 

) Any help, or pointers to further info, greatly appreciated.

) Cheers,
) Phil Watkinson,
) pkw@elgro.co.uk


--
James McIninch
School of Biology, Georgia Tech, Atlanta, GA 30332-0230
james@amber.biology.gatech.edu




Project hosted by iFAX Solutions