[OS X TeX] trim pdf figures

Siep Kroonenberg siepo at cybercomm.nl
Tue Jun 22 15:27:20 EDT 2004


On Tue, Jun 22, 2004 at 09:30:55AM -0400, Marcelo LaFleur wrote:
> I use Apple's Preview. You can  select a box around the graphic and just
> crop the page.

How safe is this for prepress purposes?

I am asking, because last week I ran into an obscure problem with an
OS X-generated pdf (producer `Mac OS X 10.3.x Quartz PDFContext',
which is what you get by this procedure), and there have been
discussions on the web about how suitable OS X native pdf support is
for prepress.

Panther has a command-line distiller pstopdf which is rumored to be
basically the Adobe distiller, and to be prepress-safe. I have been
using it for my last project in combination with a Perl script fitps:

#############################
#!/usr/bin/perl
# fitps: a script to slightly transform an EPS file so that:
#   a) it is guarenteed to start at the 0,0 coordinate
#   b) it sets a page size exactly corresponding to the BoundingBox
# This means that when GhostScript renders it, the result needs no
# cropping. GhostScript can then write a graphic file direct without
# the tedious pnmcrop etc. It needs a Level 2 PS interpreter.
#
# If the bounding box is not right, of course, you have problems...
#
# The only thing I have not allowed for is the case of
# "%%BoundingBox: (atend)", which is more complicated.
#
# Sebastian Rahtz, for Elsevier Science
$filedate="1996/07/10";
$fileversion="1.1";
$Filename=$ARGV[0];
open(TMP,"<$Filename") ||  die "Usage: fitps <filename>";
$bbneeded=1;
local $bbpatt="[0-9\.\-]";
while (<TMP>) {
 if ( /%%BoundingBox: (atend)/) {
        $bbneeded = 0;
        print;
        }
 elsif ( /%%BoundingBox:(\s$bbpatt+)\s($bbpatt+)\s($bbpatt+)\s($bbpatt+)/ )
 {
# only read the *first* bounding box
     if ($bbneeded) {
         $width = $3 - $1;
         $height = $4 - $2;
         $xoffset = 0 - $1;
         $yoffset = 0 - $2;
         print "%%BoundingBox: 0 0 $width $height\n";
         print "<< /PageSize [$width $height] >> setpagedevice\n";
         print "gsave $xoffset $yoffset translate\n";
         $bbneeded=0;
     }
# else ignore that embedded BoundingBox anyway
 }
else
 {    print;  }
}
close(TMP);
print "grestore\n";

;
##########################

This code has become part of epstopdf from teTeX, which uses
Ghostscript instead of pstopdf and also contains a lot of code to
interpret command-line option. I have been using fitps
as follows:

fitps filename.eps >filename.ps
pstopdf filename.ps

--
Siep Kroonenberg
siepo at cybercomm.nl
-----------------------------------------------------
Post: <mailto:MacOSX-TeX at email.esm.psu.edu>
Please see <http://www.esm.psu.edu/mac-tex/> for list
guidelines, information, and LaTeX/TeX resources.





More information about the MacOSX-TeX mailing list