aboutsummaryrefslogtreecommitdiff
path: root/postscript/prologues/roundpage.ps
diff options
context:
space:
mode:
Diffstat (limited to 'postscript/prologues/roundpage.ps')
-rw-r--r--postscript/prologues/roundpage.ps30
1 files changed, 30 insertions, 0 deletions
diff --git a/postscript/prologues/roundpage.ps b/postscript/prologues/roundpage.ps
new file mode 100644
index 00000000..68d2d443
--- /dev/null
+++ b/postscript/prologues/roundpage.ps
@@ -0,0 +1,30 @@
+%
+% Tries to round clipping path dimensions, as stored in array pagebbox, so they
+% match one of the known sizes in the papersizes array. Lower left coordinates
+% are always set to 0.
+%
+
+/roundpagebbox {
+ 7 dict begin
+ /papersizes [8.5 inch 11 inch 14 inch 17 inch] def
+
+ /mappapersize {
+ /val exch def
+ /slop .5 inch def
+ /diff slop def
+ /j 0 def
+ 0 1 papersizes length 1 sub {
+ /i exch def
+ papersizes i get val sub abs
+ dup diff le {/diff exch def /j i def} {pop} ifelse
+ } for
+ diff slop lt {papersizes j get} {val} ifelse
+ } def
+
+ pagebbox 0 0 put
+ pagebbox 1 0 put
+ pagebbox dup 2 get mappapersize 2 exch put
+ pagebbox dup 3 get mappapersize 3 exch put
+ end
+} bind def
+