I want to crop main area of a PS
or PDF
file to create an EPS
file without white space. Commands of ghostrcipt
, ps2pdf
, epstools
can crop the main drawing out of the document file.
The problem is that they only crop in its original form, but I want to create an EPS file with BoundingBox 0 0 x y
; cropped and moved to the bottom left corner.
The difference i when we want to insert the resulting EPS file inside a PS document. When having BoundingBox x0 y0 x y
, the PS document inserts the EPS file at point x0 y0, instead of where we are.
EXAMPLE:
Consider a simple PS
file as
%!
/Times-Roman findfont
11 scalefont setfont
72 700 moveto
(This is a test)show
if converting it to EPS
with a command like
ps2eps test.ps test.eps
It 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
It has been cropped in its original coordinates, and the resulting BoundingBox
is 72 700 127 708
. Now if trying to insert this EPS
file within a PS
document, it tries to nest at this coordinate.
It will be useful if creating an EPS
file with BoundingBox: 0 0 55 8
. Of course, all drawing coordinates (here moveto) must be modified with this new reference.
NOTE: As stated, my purpose from fixing the BoundingBox reference point is to make it importable within PS document. Thus, an alternative answer to this question is: how to insert an EPS file inside PS document regardless of its BoundingBox.
For example, how to insert this EPS file at location 200 200 255 208
of a PS document. I try to insert the EPS with the following code, but it will not work unless the BoundingBox is started from 0 0
:
200 200 translate
save
/showpage {} bind def
(test.eps)run
restore