plan9fox/sys/lib/postscript/prologues/cropmarks.ps

132 lines
3 KiB
PostScript
Raw Normal View History

%
% Center pages, based on pageheight and pagewidth, and redefine showpage
% to put cropmarks at each corner. Device dependent code to expand the
% paper size goes in procedure expandpagesize. Currently only supports
% a Linotronic 200P typesetter using 12 inch wide paper. You'll have to
% add code to expandpagesize to support different typesetters or even a
% 200P that's running differently.
%
/CropmarkDict 40 dict dup begin
/expandpage true def
/magnification 1 def
/pageheight 11.0 def
/pagewidth 8.5 def
/scaletofit false def
/scaling 1 def
/marklength .3 def % inches
/markstart .125 def % inches
/markend .04 def % inches
/marklinewidth .25 def % points
/inch {72 mul} def
/min {2 copy gt {exch} if pop} def
/max {2 copy lt {exch} if pop} def
/setup {
/markspace markstart marklength add markend add inch marklinewidth add def
/totalheight pageheight inch markspace 2 mul add def
/totalwidth pagewidth inch markspace 2 mul add def
pagedimensions
checkpagesize
/scaling getscaling def
xcenter ycenter translate
scaling scaling scale
pagewidth inch 2 div neg pageheight inch 2 div neg translate
clippage
} def
/pagedimensions {
clippath pathbbox newpath
4 -1 roll exch 4 1 roll 4 copy
sub /width exch def
sub /height exch def
add 2 div /xcenter exch def
add 2 div /ycenter exch def
} def
/checkpagesize {
height totalheight lt width totalwidth lt or expandpage and {
expandpagesize
pagedimensions
} if
} def
/expandpagesize { % device dependent code
/Product statusdict begin /product where {pop product}{()} ifelse end def
Product (Linotype) eq { % Linotronic 200P and other models?
statusdict /setpageparams known {
/maxwidth 12.0 inch def % 12 inch wide paper?
totalheight maxwidth le {
totalheight
totalwidth
maxwidth totalheight sub 2 div
0
}{
totalwidth maxwidth min
totalheight
maxwidth totalwidth maxwidth min sub 2 div
1
} ifelse
statusdict /setpageparams get exec
} if
} if
} def
/getscaling {
scaletofit
{height totalheight div width totalwidth div min 1 min}
{1}
ifelse
} def
/clippage {
newpath
0 0 moveto
pagewidth inch 0 rlineto
0 pageheight inch rlineto
pagewidth neg inch 0 rlineto
closepath clip
newpath
} def
/cropmark {
gsave
translate
rotate
marklinewidth dup translate
0 0 transform round exch round exch itransform translate
markstart inch 0 moveto marklength inch 0 rlineto stroke
0 markstart inch moveto 0 marklength inch rlineto stroke
grestore
} bind def
/@PreviousShowpage /showpage load def
end def
%
% Cropmarks - in the default coordinate system.
%
/showpage {
gsave
CropmarkDict begin
initgraphics
marklinewidth setlinewidth
xcenter ycenter translate
scaling scaling scale
0 pagewidth inch 2 div pageheight inch 2 div cropmark
90 pagewidth inch neg 2 div pageheight inch 2 div cropmark
180 pagewidth inch neg 2 div pageheight inch 2 div neg cropmark
270 pagewidth inch 2 div pageheight inch 2 div neg cropmark
@PreviousShowpage
end
grestore
} bind def