summaryrefslogtreecommitdiff
path: root/Master/texmf
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2008-01-10 11:15:30 +0000
committerNorbert Preining <preining@logic.at>2008-01-10 11:15:30 +0000
commit088962f067c15cb88f8d81ad05c357c167b7e2e0 (patch)
tree9116e84fa484fc6df014b84d06b9628811f65752 /Master/texmf
parent9448c5dc09d792001f5408fac36068ac0f1c8ea2 (diff)
updating pdfcrop in (hopefully) all necessary places ... CTAN 08-01-10
git-svn-id: svn://tug.org/texlive/trunk@6179 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf')
-rw-r--r--Master/texmf/doc/pdfcrop/README31
-rw-r--r--Master/texmf/scripts/pdfcrop/pdfcrop.pl86
2 files changed, 75 insertions, 42 deletions
diff --git a/Master/texmf/doc/pdfcrop/README b/Master/texmf/doc/pdfcrop/README
index b16d5146290..29e15beaca0 100644
--- a/Master/texmf/doc/pdfcrop/README
+++ b/Master/texmf/doc/pdfcrop/README
@@ -1,4 +1,4 @@
-README for pdfcrop 2004/06/24 v1.5
+README for pdfcrop 2008/01/09 v1.8
TABLE OF CONTENTS
=================
@@ -23,7 +23,7 @@ PDF file with removed margins.
B. COPYRIGHT, DISCLAIMER, LICENSE
=================================
-Copyright (C) 2002, 2004 Heiko Oberdiek.
+Copyright (C) 2002, 2004, 2005, 2008 Heiko Oberdiek.
This program may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either version 1.2
@@ -36,9 +36,9 @@ version 1999/12/01 or later.
C. FILES
========
The project `pdfcrop' consists of two files:
-pdfcrop(.pl): This perl script is the main program. The extension
- `.pl' may be omitted.
-README: Documentation, the file you are reading.
+pdfcrop.pl: This perl script is the main program. The extension
+ `.pl' may be omitted.
+README: Documentation, the file you are reading.
Following temporary files are produced if `pdfcrop' is invoked:
tmp-pdfcrop-*.tex: input file for pdfTeX
@@ -47,13 +47,9 @@ tmp-pdfcrop-*.pdf: result after pdfTeX run
D. REQUIREMENTS
===============
-* Perl5 (version 5 of the perl interpreter).
-* Ghostscript:
+* Perl5 (version 5 of the perl interpreter)
+* Ghostscript (>= 8.0 if PDF file contains rotated pages)
* pdfTeX, version >= 1.0 (because of page selecting and \pdfximage syntax)
-* A unix like environement is needed (Unix, cygwin, ...).
- The output of ghostscript's device bbox is written to STDERR, so
- the script has to capture STDERR. Easy under Unix, but how this
- can be done under DOS/Windows/...?
E. INSTALLATION
===============
@@ -96,8 +92,8 @@ G. AUTHOR
Heiko Oberdiek
Email: oberdiek@uni-freiburg.de
-H. ACKNOLEDGEMENT
-=================
+H. ACKNOWLEDGEMENT
+==================
Anthony Williams
Scott Pakin <pakin@uiuc.edu>
@@ -110,11 +106,13 @@ please send them to the author.
My environment for developing and testing:
* linux, SuSE 9.0
* perl v5.8.1
-* pdfeTeX 3.141592-1.20a-2.1-rc2
+* pdfeTeX 3.141592-1.21a-2.1
* Ghostscript 8.x
J. KNOWN PROBLEMS
=================
+* Perl must support open("-|"). Not every perl port supports this
+ for older windows (win95, win98).
K. HISTORY
==========
@@ -125,6 +123,11 @@ K. HISTORY
2002/11/29 v1.4: Option --papersize added.
2004/06/24 v1.5: Clear map file entries so that pdfTeX
does not touch the fonts.
+2004/06/26 v1.6: Use mgs.exe instead of gswin32c.exe for MIKTEX.
+2005/03/11 v1.7: Support of spaces in file names
+ (open("-|") is used for ghostscript call).
+2008/01/09 v1.8: Fix for moving the temporary file to the output
+ file across file system boundaries.
L. TODO
=======
diff --git a/Master/texmf/scripts/pdfcrop/pdfcrop.pl b/Master/texmf/scripts/pdfcrop/pdfcrop.pl
index c7d2319af7a..97e924b32fb 100644
--- a/Master/texmf/scripts/pdfcrop/pdfcrop.pl
+++ b/Master/texmf/scripts/pdfcrop/pdfcrop.pl
@@ -5,7 +5,7 @@ $^W=1; # turn warning on
#
# pdfcrop.pl
#
-# Copyright (C) 2002, 2004 Heiko Oberdiek.
+# Copyright (C) 2002, 2004, 2005, 2008 Heiko Oberdiek.
#
# This program may be distributed and/or modified under the
# conditions of the LaTeX Project Public License, either version 1.2
@@ -15,17 +15,17 @@ $^W=1; # turn warning on
# and version 1.2 or later is part of all distributions of LaTeX
# version 1999/12/01 or later.
#
-# See file "readme.txt" for a list of files that belong to this project.
+# See file "README" for a list of files that belong to this project.
#
# This file "pdfcrop.pl" may be renamed to "pdfcrop"
# for installation purposes.
#
my $file = "pdfcrop.pl";
my $program = uc($&) if $file =~ /^\w+/;
-my $version = "1.5";
-my $date = "2004/06/24";
+my $version = "1.8";
+my $date = "2008/01/09";
my $author = "Heiko Oberdiek";
-my $copyright = "Copyright (c) 2002, 2004 by $author.";
+my $copyright = "Copyright (c) 2002-2008 by $author.";
#
# Reqirements: Perl5, Ghostscript
# History:
@@ -36,6 +36,11 @@ my $copyright = "Copyright (c) 2002, 2004 by $author.";
# 2002/11/29 v1.4: Option --papersize added.
# 2004/06/24 v1.5: Clear map file entries so that pdfTeX
# does not touch the fonts.
+# 2004/06/26 v1.6: Use mgs.exe instead of gswin32c.exe for MIKTEX.
+# 2005/03/11 v1.7: Support of spaces in file names
+# (open("-|") is used for ghostscript call).
+# 2008/01/09 v1.8: Fix for moving the temporary file to the output
+# file across file system boundaries.
#
### program identification
@@ -51,6 +56,8 @@ $GS = "gs386" if $^O =~ /dos/i;
$GS = "gsos2" if $^O =~ /os2/i;
$GS = "gswin32c" if $^O =~ /mswin32/i;
$GS = "gswin32c" if $^O =~ /cygwin/i;
+$GS = "mgs" if defined($ENV{"TEXSYSTEM"}) and
+ $ENV{"TEXSYSTEM"} =~ /miktex/i;
# Windows detection (no SIGHUP)
my $Win = 0;
@@ -195,10 +202,19 @@ $SIG{'__DIE__'} = \&clean;
### Calculation of BoundingBoxes
-my $cmd = "$::opt_gscmd -sDEVICE=bbox -dBATCH -dNOPAUSE ";
-$cmd .= "-sPAPERSIZE=$::opt_papersize " if $::opt_papersize;
-$cmd .= "-c save pop -f " . $inputfile;
-my $cmdpipe = $cmd . " 2>&1 1>$null |";
+my @gsargs = (
+ "-sDEVICE=bbox",
+ "-dBATCH",
+ "-dNOPAUSE",
+);
+push @gsargs, "-sPAPERSIZE=$::opt_papersize" if $::opt_papersize;
+push @gsargs,
+ "-c",
+ "save",
+ "pop",
+ "-f",
+ $inputfile
+;
my $tmpfile = "$tmp.tex";
push @unlink_files, $tmpfile;
@@ -251,26 +267,35 @@ END_TMP_HEAD
print "* Running ghostscript for BoundingBox calculation ...\n"
if $::opt_verbose;
-print "* Ghostscript pipe: $cmdpipe\n" if $::opt_debug;
+print "* Ghostscript call: $::opt_gscmd @gsargs\n" if $::opt_debug;
my $page = 0;
-open(CMD, $cmdpipe) or
- die "$Error Cannot call ghostscript!\n";
-while (<CMD>) {
- my $bb = ($::opt_hires) ? "%%HiResBoundingBox" : "%%BoundingBox";
- next unless
- /^$bb:\s*([\.\d]+) ([\.\d]+) ([\.\d]+) ([\.\d]+)/o;
- $page++;
- print "* Page $page: $1 $2 $3 $4\n" if $::opt_verbose;
- if ($::opt_clip) {
- print TMP "\\pageclip $page [$1 $2 $3 $4][$llx $lly $urx $ury]\n";
- }
- else {
- my ($a, $b, $c, $d) = ($1 - $llx, $2 - $ury, $3 + $urx, $4 + $lly);
- print TMP "\\page $page [$a $b $c $d]\n";
+my $pid = open(KID_TO_READ, "-|");
+if ($pid) { # parent
+ while (<KID_TO_READ>) {
+ my $bb = ($::opt_hires) ? "%%HiResBoundingBox" : "%%BoundingBox";
+ next unless
+ /^$bb:\s*([\.\d]+) ([\.\d]+) ([\.\d]+) ([\.\d]+)/o;
+ $page++;
+ print "* Page $page: $1 $2 $3 $4\n" if $::opt_verbose;
+ if ($::opt_clip) {
+ print TMP "\\pageclip $page [$1 $2 $3 $4][$llx $lly $urx $ury]\n";
+ }
+ else {
+ my ($a, $b, $c, $d) = ($1 - $llx, $2 - $ury, $3 + $urx, $4 + $lly);
+ print TMP "\\page $page [$a $b $c $d]\n";
+ }
}
+ close(KID_TO_READ)
+ || die "!!! Error: Execution of ghostscript failed: $?\n";
+}
+else { # child
+ open STDERR, '>&STDOUT' or die "!!! Error: Cannot redirect stderr: $!\n";
+ open STDOUT, ">$null" or die "!!! Error: Cannot write to $null!\n";
+ exec($::opt_gscmd, @gsargs)
+ || die "!!! Error: Ghostscript run failed: $!\n";
+ # NOT REACHED
}
-close(CMD);
print TMP "\\csname \@\@end\\endcsname\n\\end\n";
close(TMP);
@@ -278,6 +303,7 @@ close(TMP);
### Run pdfTeX
push @unlink_files, "$tmp.log";
+my $cmd;
if ($::opt_verbose) {
$cmd = "$::opt_pdftexcmd -interaction=nonstopmode $tmp";
}
@@ -297,10 +323,14 @@ if ($?) {
}
### Move temp file to output
-rename "$tmp.pdf", $outputfile or
- die "$Error Cannot move `$tmp.pdf' to `$outputfile'!\n";
+if (!rename("$tmp.pdf", $outputfile)) {
+ use File::Copy;
+ move "$tmp.pdf", $outputfile or
+ die "$Error Cannot move `$tmp.pdf' to `$outputfile'!\n";
+}
-print "==> $page pages written on `$outputfile'.\n";
+print "==> $page page", (($page == 1) ? "" : "s"),
+ " written on `$outputfile'.\n";
$exit_code = 0;
cleanup();