How to set up a BoundingBox EPS file?

I want to trim the main area of ​​a file PSor PDFto create a file EPSwithout a space. Team ghostrcipt, ps2pdf, epstoolscan cut the main drawing of the document file.

The problem is that they are only cropped in their original form, but I want to create an EPS file with BoundingBox 0 0 x y; cropped and moved to the lower left corner.

The difference is i, when we want to insert the resulting EPS file inside the PS document. When BoundingBox x0 y0 x y, a PS document inserts an EPS file at x0 y0 instead of where we are.

Example:

Consider a simple file PSas

%!
/Times-Roman findfont 
11 scalefont setfont

72 700 moveto
(This is a test)show

if you convert it to EPSusing a command like

ps2eps test.ps test.eps

He will produce

%!PS-Adobe-2.0 EPSF-2.0
%%BoundingBox: 72 700 127 708
%%HiResBoundingBox: 72.000000 700.000000 127.000000 707.500000
%%EndComments
% EPSF created by ps2eps 1.68
%%BeginProlog
save
countdictstack
mark
newpath
/showpage {} def
/setpagedevice {pop} def
%%EndProlog
%%Page 1 1
/Times-Roman findfont 
11 scalefont setfont
72 700 moveto
(This is a test)show
%%Trailer
cleartomark
countdictstack
exch sub { end } repeat
restore
%%EOF

, BoundingBox 72 700 127 708. , EPS PS, .

EPS BoundingBox: 0 0 55 8. , ( moveto) .

.. , - BoundingBox, PS. , : EPS PS BoundingBox.

, EPS 200 200 255 208 PS. EPS , , BoundingBox 0 0:

200 200 translate 
save 
/showpage {} bind def 
(test.eps)run 
restore
+5
2

?

-72 -700 translate

eps, ?


!

typescript awk script, eps, DSC ( !).

: , EPS DSC , , ghostscript.

- , . DSC, BoundingBox, HiResBoundingBox postcript 'translate' 'rectclip' . , EPS bona-fide. ghostscript DSC ( , DSC ).

, "" , , "".

592(1)11:27 AM:~ 0> cat epscrop.awk
/%%BoundingBox: ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*)/{x=$2;y=$3;w=$4-x;h=$5-y;print $1,0,0,w,h}
!/%%BoundingBox:/&&!/%%HiRes/{print}
/%%Page /{print -x,-y,"translate"; print 0,0,w,h,"rectclip"}


593(1)11:27 AM:~ 0> awk -f epscrop.awk etest.eps
%!PS-Adobe-2.0 EPSF-2.0
%%BoundingBox: 0 0 55 8
%%EndComments
% EPSF created by ps2eps 1.68
%%BeginProlog
save
countdictstack
mark
newpath
/showpage {} def
/setpagedevice {pop} def
%%EndProlog
%%Page 1 1
-72 -700 translate
0 0 55 8 rectclip
/Times-Roman findfont
11 scalefont setfont
72 700 moveto
(This is a test)show
%%Trailer
cleartomark
countdictstack
exch sub { end } repeat
restore
%%EOF
+2

EPS BoundingBox-, , Ghostscript EPS : EPS = > PDF = > EPS.

, PDF- , BoundingBox, -dEPSCrop.

EPS :

1- : EPS PDF:

gs                   \
  -o so#12682621.pdf \
  -sDEVICE=pdfwrite  \
  -dEPSCrop          \
   so#12682621.eps

: PDF EPS:

gs                                \
  -o so#12682621.roundtripped.eps \
  -sDEVICE=epswrite               \
   so#12682621.pdf 

EPS, ImageMagick compare, , PNG :

 compare                      \
   -density 600               \
    12682621.roundtripped.eps \
    12682621.eps              \
   -compose src               \
    12682621.png

: enter image description here

, . 707.500000 %%HiResBoundingBox, (PNG " " ).

+3

All Articles