Go to the first, previous, next, last section, table of contents.


PostScript hooks

Besides including literal PostScript at a particular place in your document (as described in the previous section), you can also arrange to execute arbitrary PostScript code at particular times while the PostScript is printing.

If any of the PostScript names bop-hook, eop-hook, start-hook, or end-hook are defined in userdict, they will be executed at the beginning of a page, end of a page, start of the document, and end of a document, respectively.

When these macros are executed, the default PostScript coordinate system and origin is in effect. Such macros can be defined in headers added by the `-h' option or the `header=' special, and might be useful for writing, for instance, `DRAFT' across the entire page, or, with the aid of a shell script, dating the document. These macros are executed outside of the save/restore context of the individual pages, so it is possible for them to accumulate information, but if a document must be divided into sections because of memory constraints, such added information will be lost across section breaks.

The single argument to bop-hook is the physical page number; the first page gets zero, the second one, etc. bop-hook must leave this number on the stack. None of the other hooks are passed arguments.

As an example of what can be done, the following special will write a light grey `DRAFT' across each page in the document:

\special{!userdict begin /bop-hook{gsave 200 30 translate
65 rotate /Times-Roman findfont 216 scalefont setfont
0 0 moveto 0.7 setgray (DRAFT) show grestore}def end}

Using bop-hook or eop-hook to preserve information across pages breaks compliance with the Adobe document structuring conventions, so if you use any such tricks, you may also want to use the `-N' option to turn off structured comments (such as `%%Page'). Otherwise, programs that read your file will assume its pages are independent.


Go to the first, previous, next, last section, table of contents.