roundpage.ps 695 B

123456789101112131415161718192021222324252627282930
  1. %
  2. % Tries to round clipping path dimensions, as stored in array pagebbox, so they
  3. % match one of the known sizes in the papersizes array. Lower left coordinates
  4. % are always set to 0.
  5. %
  6. /roundpagebbox {
  7. 7 dict begin
  8. /papersizes [8.5 inch 11 inch 14 inch 17 inch] def
  9. /mappapersize {
  10. /val exch def
  11. /slop .5 inch def
  12. /diff slop def
  13. /j 0 def
  14. 0 1 papersizes length 1 sub {
  15. /i exch def
  16. papersizes i get val sub abs
  17. dup diff le {/diff exch def /j i def} {pop} ifelse
  18. } for
  19. diff slop lt {papersizes j get} {val} ifelse
  20. } def
  21. pagebbox 0 0 put
  22. pagebbox 1 0 put
  23. pagebbox dup 2 get mappapersize 2 exch put
  24. pagebbox dup 3 get mappapersize 3 exch put
  25. end
  26. } bind def