LATEX-L Archives

Mailing list for the LaTeX3 project


Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Mailing list for the LaTeX3 project <[log in to unmask]>
"Nelson H. F. Beebe" <[log in to unmask]>
Mon, 2 Mar 2009 16:04:13 -0700
Mailing list for the LaTeX3 project <[log in to unmask]>
text/plain (122 lines)
I agree with Karl that a simple solution for the current inability of
PDFTeX to import EPS files would be helpful.

However, in my substantial (and long) experience with PostScript and
PDF, one of the thorny issues is that of the image \emph{bounding

PostScript supports it only as a comment:

	%%BoundingBox: llx lly urx ury

where ll is lower-left, ur is upper-right, and the four values are in
PostScript's big points (72bp == 1in = 25.4mm)).  

PDF has at least five such boxes:


Most PostScript- and PDF-producing software get these values wrong,
including Adobe's own PostScript-to-PDF conversion tool, Distiller.

The bounding box is an essential piece of information needed by TeX
and DVI drivers to scale and position EPS files correctly in typeset

Several years ago, at my request, L. Peter Deutsch, the originator and
chief architect of ghostscript (now retired from that job) added a
feature to ghostscript to compute an exact bounding box from the
actual bitmap image created by the PostScript conversion.  I've used
the facilty for many years in a little Unix shell script given at the
end of this message.

Distiller also has a nasty bug wherein it arbitrarily rotates EPS
figures by 90 degrees, making it impossible to use reliably on large
batches of EPS files.  I posted a bug report to Adobe several years
ago that showed differing rotation behavior between two short test
files that differed only in a comment line!  Since there has never
been a newer version of Distiller for Unix systems, any fix that might
be available in the Windows & Mac worlds is inaccessible to me.

Another problem is that PostScript-to-PDF conversion, whether by Adobe
Distiller, Ghostscript ps2pdf, or Frank Siegert's PStill, sometimes
results in significant file expansion, or downsampling of image
resolution.  While control of these features is available via
command-line options, it is difficult for most users to get right.

% cat
#! /bin/sh -
# Run Adobe Acrobat Distiller and Exchange to clean up one or more
# PostScript files, and then use ghostscript to compute an exact
# bounding box which is automatically inserted into the file.
# The original input files are preserved with an extension .original,
# and the new versions replace the original ones.
# The new output files use Level 2 PostScript, for compactness.
# They may not be printable on older PostScript devices.
# This version works with gs-5.40 or later.
# Usage:
#	./ PostScript-file(s)
# [09-Dec-1998] : MODIFIED VERSION: Suppresses distill/acroexch step, and inserts
#                 generated bounding box comments after first line of each file
# [22-Sep-1998]


# [03-Jul-2003] Make ghostscript version selectable at run time
# gs bug report #686892 notes failure of the bbox device in 8.10,
# so we default the most recent working version, sigh...

trap "rm -f $pdffile $sedscript" 0 1 2 3 15

for f in "$@"
	g=`echo $f | sed -e 's/[.][^.]*$//'`
	echo ==================== $g
	mv $f $f.original

	# We need a filtering step to remove three kinds of DSC lines
	# whose presence would otherwise influence distiller.  In
	# addition, the system defaults file,
	# /usr/local/sys/adobe/Acrobat3/Distillr/Startup/,
	# and symlinks to it from versions 3.01, 3.02, ... has been
	# modified to add the line
	# << /AutoRotatePages /None >> setdistillerparams
	# just before the end.  This is still not sufficient to
	# prevent autorotation of some images: while it stops distill
	# from doing it, acroexch will do it.

	$GS -sDEVICE=bbox -dNOPAUSE $f.original 2>&1 | $bindir/gawk '
/%%BoundingBox:/	{ printf("2i\\\n%s\\\n",$0) }
/%%HiResBoundingBox:/	{ print ; exit(0) }
' >$sedscript
	chmod +x $sedscript
	if $bindir/sed -f $sedscript < $f.original > $f
		echo "Output failure at file $f : is the disk full???"
		rm -f $sedscript
		exit 1

- Nelson H. F. Beebe                    Tel: +1 801 581 5254                  -
- University of Utah                    FAX: +1 801 581 4148                  -
- Department of Mathematics, 110 LCB    Internet e-mail: [log in to unmask]  -
- 155 S 1400 E RM 233                       [log in to unmask]  [log in to unmask] -
- Salt Lake City, UT 84112-0090, USA    URL: -