summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-07-17 00:59:32 +0000
committerKarl Berry <karl@freefriends.org>2009-07-17 00:59:32 +0000
commit076fafe106fea5f8bb247a0b9ef5f913ce341311 (patch)
tree09e36ff5bd4c6eba71849dc7e0828f3890489a78
parentc952cbb692e8859d785a93ba914937a94aff1269 (diff)
pdfcrop 1.15 (14jul09)
git-svn-id: svn://tug.org/texlive/trunk@14291 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-xBuild/source/texk/texlive/linked_scripts/pdfcrop/pdfcrop.pl64
-rw-r--r--Master/texmf-dist/doc/support/pdfcrop/README19
-rwxr-xr-xMaster/texmf-dist/scripts/pdfcrop/pdfcrop.pl12
3 files changed, 76 insertions, 19 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/pdfcrop/pdfcrop.pl b/Build/source/texk/texlive/linked_scripts/pdfcrop/pdfcrop.pl
index 70c85483670..412e979ac50 100755
--- a/Build/source/texk/texlive/linked_scripts/pdfcrop/pdfcrop.pl
+++ b/Build/source/texk/texlive/linked_scripts/pdfcrop/pdfcrop.pl
@@ -5,7 +5,7 @@ $^W=1; # turn warning on
#
# pdfcrop.pl
#
-# Copyright (C) 2002, 2004, 2005, 2008 Heiko Oberdiek.
+# Copyright (C) 2002, 2004, 2005, 2008, 2009 Heiko Oberdiek.
#
# This program may be distributed and/or modified under the
# conditions of the LaTeX Project Public License, either version 1.2
@@ -22,10 +22,10 @@ $^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.15";
+my $date = "2009/07/14";
my $author = "Heiko Oberdiek";
-my $copyright = "Copyright (c) 2002-2008 by $author.";
+my $copyright = "Copyright (c) 2002-2009 by $author.";
#
# Reqirements: Perl5, Ghostscript
# History:
@@ -49,6 +49,9 @@ 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.
+# 2009/07/14 v1.15: Fix for negative coordinates in Bounding Boxes
+# (David Menestrina).
### program identification
my $title = "$program $version, $date - $copyright\n";
@@ -334,6 +337,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
@@ -388,16 +403,51 @@ my $bb = ($::opt_hires) ? "%%HiResBoundingBox" : "%%BoundingBox";
while (<GS>) {
print $_ if $::opt_verbose;
next unless
- /^$bb:\s*([\.\d]+) ([\.\d]+) ([\.\d]+) ([\.\d]+)/o;
+ /^$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";
}
}
diff --git a/Master/texmf-dist/doc/support/pdfcrop/README b/Master/texmf-dist/doc/support/pdfcrop/README
index d9a0e4d6e21..9d47638d3f6 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/09/12 v1.14
+README for pdfcrop 2009/07/14 v1.15
TABLE OF CONTENTS
=================
@@ -23,7 +23,7 @@ PDF file with removed margins.
B. COPYRIGHT, DISCLAIMER, LICENSE
=================================
-Copyright (C) 2002, 2004, 2005, 2008 Heiko Oberdiek.
+Copyright (C) 2002, 2004, 2005, 2008, 2009 Heiko Oberdiek.
This program may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either version 1.2
@@ -56,8 +56,8 @@ E. INSTALLATION
1. Perl script `pdfcrop.pl':
- TDS 1.1 location:
- * texmf/scripts/pdfcrop/pdfcrop.pl
+ TDS 1.1 location (TDS means "texmf" tree, see CTAN:tds/tds.pdf):
+ * TDS:scripts/pdfcrop/pdfcrop.pl
* and a directory that is part of PATH contains a wrapper script
or link with name "pdfcrop".
@@ -69,15 +69,15 @@ E. INSTALLATION
* Move the file to a directory where the shell can find it
(environment variable PATH, e.g. /usr/local/bin/).
- Dos/Windows/(OS2)
+ Dos/Windows
* See requirements. I do not expect that the perl script
- run under DOS or Windows. With cygwin it can work however.
+ run under DOS.
2. Documentation `README':
Copy it to an appropriate place, for example
`/usr/local/share/doc/pdfcrop/README'.
- I is allowed to rename it to `pdfcrop.txt'.
+ It is allowed to rename it to `pdfcrop.txt'.
TDS location:
somewhere below texmf/doc/... (?)
@@ -85,6 +85,8 @@ E. INSTALLATION
TDS:doc/support/pdfcrop/README
TDS:doc/scripts/pdfcrop/README
TDS:doc/scripts/pdfcrop.txt
+ TeXLive 2008 and 2009 put it in
+ TDS:doc/support/pdfcrop/README
F. USER INTERFACE
=================
@@ -110,6 +112,7 @@ Ionut Georgescu
Yves J\"ager
R (Chandra) Chandrasekhar
Christian Stapfer
+David Menestrina
I. QUESTIONS, SUGGESTED IMPROVEMENTS
====================================
@@ -153,6 +156,8 @@ K. HISTORY
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.
+2009/07/14 v1.15: Fix for negative coordinates in Bounding Boxes
+ (David Menestrina).
L. TODO
=======
diff --git a/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl b/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl
index a8768f0ef0d..412e979ac50 100755
--- a/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl
+++ b/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl
@@ -5,7 +5,7 @@ $^W=1; # turn warning on
#
# pdfcrop.pl
#
-# Copyright (C) 2002, 2004, 2005, 2008 Heiko Oberdiek.
+# Copyright (C) 2002, 2004, 2005, 2008, 2009 Heiko Oberdiek.
#
# This program may be distributed and/or modified under the
# conditions of the LaTeX Project Public License, either version 1.2
@@ -22,10 +22,10 @@ $^W=1; # turn warning on
#
my $file = "pdfcrop.pl";
my $program = uc($&) if $file =~ /^\w+/;
-my $version = "1.14";
-my $date = "2008/09/12";
+my $version = "1.15";
+my $date = "2009/07/14";
my $author = "Heiko Oberdiek";
-my $copyright = "Copyright (c) 2002-2008 by $author.";
+my $copyright = "Copyright (c) 2002-2009 by $author.";
#
# Reqirements: Perl5, Ghostscript
# History:
@@ -50,6 +50,8 @@ my $copyright = "Copyright (c) 2002-2008 by $author.";
# 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.
+# 2009/07/14 v1.15: Fix for negative coordinates in Bounding Boxes
+# (David Menestrina).
### program identification
my $title = "$program $version, $date - $copyright\n";
@@ -401,7 +403,7 @@ my $bb = ($::opt_hires) ? "%%HiResBoundingBox" : "%%BoundingBox";
while (<GS>) {
print $_ if $::opt_verbose;
next unless
- /^$bb:\s*([\.\d]+) ([\.\d]+) ([\.\d]+) ([\.\d]+)/o;
+ /^$bb:\s*(-?[\.\d]+) (-?[\.\d]+) (-?[\.\d]+) (-?[\.\d]+)/o;
@bbox = ($1, $2, $3, $4) unless $::opt_bbox;
$page++;