+
+ % ---- translate to bottom-right corner of Portrait page
+ LandscapeMode{
+ LandscapePageHeight 0 translate
+ 90 rotate
+ }if
+ % ---- [jack] Kludge: my ghostscript window is 21x27.7 instead of 21x29.7
+ /JackGhostscript where{pop 1 27.7 29.7 div scale}if
+ UpsideDown{PageWidth LandscapePageHeight translate 180 rotate}if
+ % ---- N-Up printing
+ N-Up 1 gt{
+ % ---- landscape
+ N-Up-Landscape{
+ PageWidth 0 translate
+ 90 rotate
+ }if
+ N-Up-Margin dup translate
+ % ---- scale
+ LandscapeMode{
+ /HH PageWidth def
+ /WW LandscapePageHeight def
+ }{
+ /HH LandscapePageHeight def
+ /WW PageWidth def
+ }ifelse
+ /xx 0 def
+ N-Up-Landscape{
+ /ww WW WW mul N-Up-Lines HH mul div def
+ /cc HH N-Up-Columns N-Up-Missing add div def
+ ww cc gt{/xx WW def/WW cc ww div WW mul def/xx xx WW sub def}if
+ }{
+ /hh HH N-Up-Columns N-Up-Missing add div def
+ /cc HH N-Up-Lines div def
+ hh cc gt{/xx WW def/WW cc hh div WW mul def/xx xx WW sub def}if
+ }ifelse
+ WW N-Up-Margin sub N-Up-Margin sub
+ N-Up-Landscape
+ {N-Up-Lines div HH}
+ {N-Up-Columns N-Up-Missing add div WW}ifelse
+ div dup scale
+ LandscapeMode{/yy 0 def}{/yy xx def/xx 0 def}ifelse
+ xx N-Up-Repeat 1 sub LandscapePageHeight mul yy add translate
+ % ---- go to start position in page matrix
+ N-Up-XStart N-Up-Missing 0.5 mul
+ LandscapeMode
+ {LandscapePageHeight mul N-Up-YStart add}
+ {PageWidth mul add N-Up-YStart}ifelse
+ translate
+ }if
+ % ---- translate to lower left corner of TEXT
+ TextStart translate
+