summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2008-09-15 00:05:12 +0000
committerKarl Berry <karl@freefriends.org>2008-09-15 00:05:12 +0000
commit90a433f9ea443c3b90c7c00c17f4ea621b50497a (patch)
tree101fcc1afe7460641a311968766fcea64a86897e /Master/texmf-dist/scripts
parenta3284885d98386fd05b934e65a642eeb1ac5093a (diff)
pdfcrop 1.14 (12sep08)
git-svn-id: svn://tug.org/texlive/trunk@10596 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts')
-rwxr-xr-xMaster/texmf-dist/scripts/pdfcrop/pdfcrop.pl56
1 files changed, 52 insertions, 4 deletions
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 (<GS>) {
/^$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";
}
}