%! % POSTSCRIPT SHOWPAGE DIVERTER % ============================ % Copyright c 2000 by Don Lancaster and Synergetics, Box 809, Thatcher, AZ, 85552 % (520) 428-4073 don@tinaja.com http://www.tinaja.com % Consulting services available per http://www.tinaja.com/info01.html % All commercial rights and all electronic media rights fully reserved. % Linking welcome. Reposting expressly forbidden. Version 1.3 % One of the incredibly powerful features of the PostScript language is that % most any proc can be redefined at any time. Even to a different type. % Redefining the ~showpage~ operator can be particularly useful. For providing % web undercolor or watermarks, adding page numbers, standardizing borders, % selectively adding specific page features, doing right-left,logos, etc... true setglobal % persist on save/restores globaldict begin /validpage false store % use for first underlay /pagenumber 1 store % running page number /realshowpage {systemdict /showpage get exec} def % grab real showpage /showpage { % redefine custom showpage validpage{ % if not setup [{overproc1}{overproc2}{overproc3}] {cvx exec} forall % do overprocs realshowpage % do real showpage /pagenumber pagenumber 1 add store % adjust page number } if /validpage true store % after setup [{underproc1}{underproc2}{underproc3}] {cvx exec} forall % do underprocs } def /overproc1 {} def /overproc2 {} def /overproc3 {} def % default null procs /underproc1 {} def /underproc2 {} def /underproc3 {} def % /underproc1 gives a color background to part of each page. In this example, page three % is conditionally made a different color... /underproc1 { gsave pagenumber 3 eq {1 1 0.8}{1 0.8 1} ifelse setrgbcolor % pick some colors 0 0 moveto 1000 0 rlineto 0 425 rlineto -1000 0 rlineto % fill page with color closepath fill grestore} def % /overproc1 gives a border and a page number to each page... /overproc1 {gsave /in {72 mul} def % adjust size 0.5 in 0.5 in moveto % rectanglular box 0 in 10 in rlineto 7.5 in 0 rlineto 0 in -10 in rlineto closepath 5 setlinewidth 1 setlinecap 1 setlinejoin stroke /Helvetica findfont 10 scalefont setfont % add page number 0.8 in 0.8 in moveto (page ) show pagenumber 10 string cvs show grestore} def % A fake first page must ~always~ be used to start the underlay process... showpage % set up first page underlay % This demo represents your original document... /demo {/Helvetica findfont 12 scalefont setfont 100 300 moveto (This is the original first page) show showpage 100 300 moveto (This is the original second page) show showpage 100 300 moveto (This is the original third page) show showpage 100 300 moveto (This is the original fourth page) show showpage } def end % cease persistent false setglobal % As a demo, send the following code to Distiller (preferred) or to % GhostScript or to a PostScript sepaking printer... demo % run demo % To divert showpage on third party documents, set the above up as one or more files % and add an ~uncommented~ line similar to.... %% (E:\\medocs-E\\divertsp\\divsp01.ps) run % near the beginning of each document to be overlayed or underlayed. Be CERTAIN to % use "\\" every time you mean "\". If you are working with existing .PDF files, % print to disk as PostScript, enter the diversion line, and then redistill. % Original code that misuses the ~initgraphics~ command or does other strange things in % strange ways may require modification for showpage diversion. Other code may overwrite % certain underproc colors or images in certain positions. % A blank "underlayed only" page may end up at the end and can be removed with Exchange. % Demos and sourcecode available at http://www.tinaja.com/post01.html and at % http://www.tinaja.com/acrob01.html % Consulting assistance is available per don@tinaja.com %% EOF