3 .\" .EPS file.eps [L|R|C|indents] [width] [height]
5 . ds eps.tmp /tmp/.eps.\n($$
6 . \" obtaing the bounding box
8 . ie '@$0'.PDF' .sy cat "@$1" | sed -n '/^.*MediaBox *\[ *\([-.0123456789]\{1,10\}\) *\([-.0123456789]\{1,10\}\) *\([-.0123456789]\{1,10\}\) *\([-.0123456789]\{1,10\}\) *\].*$/{s//.nr llx 0+\1p,.nr lly 0+\2p,.nr urx 0+\3p,.nr ury 0+\4p/p; q; }' | tr ',' '\\n' >@*[eps.tmp]
9 . el .sy cat "@$1" | sed -n '/%%BoundingBox: *\([-0123456789]\{1,10\}\) *\([-0123456789]\{1,10\}\) *\([-0123456789]\{1,10\}\) *\([-0123456789]\{1,10\}\)/{s//.nr llx 0+\1p,.nr lly 0+\2p,.nr urx 0+\3p,.nr ury 0+\4p/p; q; }' | tr ',' '\\n' >@*[eps.tmp]
14 . ie '\\$3'' .nr eps.scale 100
15 . el .nr eps.scale ((\\$3)*100/(\\n[urx]-\\n[llx]))
16 . if !'\\$4'' .if \\n[eps.scale]>(((\\$4)*100/(\\n[ury]-\\n[lly]))) \
17 . nr eps.scale ((\\$4)*100/(\\n[ury]-\\n[lly]))
18 . nr eps.w (\\n[urx]-\\n[llx])*\\n[eps.scale]/100
19 . nr eps.h (\\n[ury]-\\n[lly])*\\n[eps.scale]/100
21 . ie '\\$2'' .nr eps.in 0
22 . el .nr eps.in (\\$2)
23 . if '\\$2'L' .nr eps.in 0
24 . if '\\$2'C' .nr eps.in (\\n(.l-\\n(.i-\\n[eps.w])/2
25 . if '\\$2'R' .nr eps.in (\\n(.l-\\n(.i-\\n[eps.w])
26 . \" printing the image
30 . ie '\\$0'.PDF' \h'|\\n[eps.in]u'\\X'pdf "\\$1" \\n[eps.w]'\h'\\n[eps.w]u'
31 . el \h'|\\n[eps.in]u'\\X'eps "\\$1" \\n[eps.w]'\h'\\n[eps.w]u'
34 .\" .PDF file.pdf [L|R|C|indents] [width] [height]