henesyinit from p9fce6d0435 years agoHistory
36 lines · 2.4 KB · Prolog
RawDownload
%!/setupforms{/landscape exch def /formsperpage exch def /rotation 1 defuserdict /currentform 0 put /slop 5 def /min{2 copy gt{exch}if pop}def/columns formsperpage sqrt ceiling cvi def /rows formsperpage columnsdiv ceiling cvi def 6 array defaultmatrix 6 array currentmatrix 6 arrayinvertmatrix 6 array concatmatrix /tempmatrix exch def 0 slop tempmatrixdtransform dup mul exch dup mul add sqrt /slop exch def newpath clippathpathbbox 2 index sub dup /formheight exch def slop 2 mul sub /pageheightexch def 2 index sub dup /formwidth exch def slop 2 mul sub /pagewidthexch def userdict /gotpagebbox known userdict /pagebbox known and{newpath pagebbox 0 get pagebbox 1 get tempmatrix transform movetopagebbox 0 get pagebbox 3 get tempmatrix transform lineto pagebbox 2 getpagebbox 3 get tempmatrix transform lineto pagebbox 2 get pagebbox 1 gettempmatrix transform lineto closepath pathbbox 2 index sub /formheightexch def 2 index sub /formwidth exch def}{2 copy}ifelse /ycorner exchdef /xcorner exch def translate slop slop translate pagewidth pageheightgt{rows columns /rows exch def /columns exch def}if pagewidth formwidthcolumns mul div pageheight formheight rows mul div min pageheightformwidth columns mul div pagewidth formheight rows mul div min 2 copylt{rotation 1 eq{landscape{0 pageheight translate -90 rotate}{pagewidth0 translate 90 rotate}ifelse}{landscape{pagewidth 0 translate 90 rotate}{0 pageheight translate -90 rotate}ifelse}ifelse pagewidth pageheight/pagewidth exch def /pageheight exch def exch}if pop dup dup scalexcorner neg ycorner neg translate 0 rows 1 sub formheight mul translatedup pagewidth exch div formwidth columns mul sub 2 div exch pageheightexch div formheight rows mul sub 2 div translate /showpage{formsperpage1 gt{gsave .1 setlinewidth outlineform stroke grestore}if formwidth 0translate userdict /currentform currentform 1 add put currentformcolumns mod 0 eq{columns formwidth mul neg formheight neg translate}ifcurrentform formsperpage mod 0 eq{gsave showpage grestore currentformcolumns mod formwidth mul neg formsperpage columns idiv formheight multranslate userdict /currentform 0 put}if}bind def /outlineform{newpathxcorner ycorner moveto formwidth 0 rlineto 0 formheight rlinetoformwidth neg 0 rlineto closepath}bind def /lastpage{formsperpage 1 gt{currentform 0 ne{0 1 formsperpage currentform sub formsperpage mod{popshowpage}for}if}if}def userdict /end-hook{lastpage}put newpath}def