From 90a433f9ea443c3b90c7c00c17f4ea621b50497a Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 15 Sep 2008 00:05:12 +0000 Subject: pdfcrop 1.14 (12sep08) git-svn-id: svn://tug.org/texlive/trunk@10596 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/support/pdfcrop/README | 10 +++-- Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl | 56 ++++++++++++++++++++++++++-- 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/Master/texmf-dist/doc/support/pdfcrop/README b/Master/texmf-dist/doc/support/pdfcrop/README index 8454a946a34..d9a0e4d6e21 100644 --- a/Master/texmf-dist/doc/support/pdfcrop/README +++ b/Master/texmf-dist/doc/support/pdfcrop/README @@ -1,4 +1,4 @@ -README for pdfcrop 2008/07/24 v1.13 +README for pdfcrop 2008/09/12 v1.14 TABLE OF CONTENTS ================= @@ -125,9 +125,10 @@ My environment for developing and testing: J. KNOWN PROBLEMS ================= -* Some Perl versions (newer Perl on Windows) miss open("-|"). - This should be fixed in version 1.11 by a workaround found in - http://perldoc.perl.org/perlfork.html. +* pdfcrop relies on Ghostscript for the calculation of the + Bounding Box. If Ghostscript returns wrong values or + cannot process the pdf file, it sometimes helps to try + another version of Ghostscript. K. HISTORY ========== @@ -151,6 +152,7 @@ K. HISTORY 2008/07/24 v1.13: open("-|")/workaround removed. Input files with unsafe file names are linked/copied to temporary file with safe file name. +2008/09/12 v1.14: Error detection for invalid Bounding Boxes. L. TODO ======= diff --git a/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl b/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl index 70c85483670..a8768f0ef0d 100755 --- a/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl +++ b/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl @@ -22,8 +22,8 @@ $^W=1; # turn warning on # my $file = "pdfcrop.pl"; my $program = uc($&) if $file =~ /^\w+/; -my $version = "1.13"; -my $date = "2008/07/24"; +my $version = "1.14"; +my $date = "2008/09/12"; my $author = "Heiko Oberdiek"; my $copyright = "Copyright (c) 2002-2008 by $author."; # @@ -49,6 +49,7 @@ my $copyright = "Copyright (c) 2002-2008 by $author."; # 2008/07/24 v1.13: open("-|")/workaround removed. # Input files with unsafe file names are linked/copied # to temporary file with safe file name. +# 2008/09/12 v1.14: Error detection for invalid Bounding Boxes. ### program identification my $title = "$program $version, $date - $copyright\n"; @@ -334,6 +335,18 @@ if ($::opt_tex eq 'pdftex') { \pdfxform0\relax \shipout\hbox{\pdfrefxform\pdflastxform}% }% +\def\pageinclude#1{% + \pdfhorigin=0pt\relax + \pdfvorigin=0pt\relax + \pdfximage page #1{\pdffile}% + \setbox0=\hbox{\pdfrefximage\pdflastximage}% + \pdfpagewidth=\wd0\relax + \pdfpageheight=\ht0\relax + \advance\pdfpageheight by \dp0\relax + \shipout\hbox{% + \raise\dp0\box0\relax + }% +} END_TMP_HEAD } else { # XeTeX @@ -391,13 +404,48 @@ while () { /^$bb:\s*([\.\d]+) ([\.\d]+) ([\.\d]+) ([\.\d]+)/o; @bbox = ($1, $2, $3, $4) unless $::opt_bbox; $page++; + + my $empty = 0; + $empty = 1 if $bbox[0] >= $bbox[2]; + $empty = 1 if $bbox[1] >= $bbox[3]; + if ($empty) { + print <<"END_WARNING"; + +!!! Warning: Empty Bounding Box is returned by Ghostscript! +!!! Page $page: @bbox +!!! Either there is a problem with the page or with Ghostscript. +!!! Recovery is tried by embedding the page in its original size. + +END_WARNING + print TMP "\\pageinclude{$page}\n"; + next; + } + print "* Page $page: @bbox\n" if $::opt_verbose; + + my @bb = ($bbox[0] - $llx, $bbox[1] - $ury, + $bbox[2] + $urx, $bbox[3] + $lly); + + $empty = 0; + $empty = 1 if $bb[0] >= $bb[2]; + $empty = 1 if $bb[1] >= $bb[3]; + if ($empty) { + print <<"END_WARNING"; + +!!! Warning: The final Bounding Box is empty! +!!! Page: $page: @bb +!!! Probably caused by too large negative margin values. +!!! Recovery by ignoring margin values. + +END_WARNING + print TMP "\\page $page [@bbox]\n"; + # clipping shouldn't make a difference + next; + } if ($::opt_clip) { print TMP "\\pageclip $page [@bbox][$llx $lly $urx $ury]\n"; } else { - my @bb = ($bbox[0] - $llx, $bbox[1] - $ury, - $bbox[2] + $urx, $bbox[3] + $lly); print TMP "\\page $page [@bb]\n"; } } -- cgit v1.2.3