From 3458209effc92485ac1e25e38c0bfefdf0efe62a Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 17 Jul 2008 23:07:21 +0000 Subject: pdfcrop update (17jul08) git-svn-id: svn://tug.org/texlive/trunk@9646 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/generic/pdfcrop/README | 41 ++++++----- Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl | 101 +++++++++++++++++++++------ 2 files changed, 102 insertions(+), 40 deletions(-) diff --git a/Master/texmf-dist/doc/generic/pdfcrop/README b/Master/texmf-dist/doc/generic/pdfcrop/README index 19d55cdcd5a..b088c7e5d6a 100644 --- a/Master/texmf-dist/doc/generic/pdfcrop/README +++ b/Master/texmf-dist/doc/generic/pdfcrop/README @@ -1,4 +1,4 @@ -README for pdfcrop 2008/04/05 v1.9 +README for pdfcrop 2008/07/16 v1.10 TABLE OF CONTENTS ================= @@ -81,6 +81,10 @@ E. INSTALLATION TDS location: somewhere below texmf/doc/... (?) + Examples: + TDS:doc/support/pdfcrop/README + TDS:doc/scripts/pdfcrop/README + TDS:doc/scripts/pdfcrop.txt F. USER INTERFACE ================= @@ -96,14 +100,15 @@ F. USER INTERFACE G. AUTHOR ========= Heiko Oberdiek -Email: oberdiek@uni-freiburg.de +Email: oberdiek at uni-freiburg.de H. ACKNOWLEDGEMENT ================== Anthony Williams -Scott Pakin +Scott Pakin Ionut Georgescu Yves J\"ager +R (Chandra) Chandrasekhar I. QUESTIONS, SUGGESTED IMPROVEMENTS ==================================== @@ -114,7 +119,7 @@ please send them to the author. My environment for developing and testing: * linux, SuSE 9.0 * perl v5.8.1 -* pdfeTeX 3.141592-1.21a-2.1 +* pdfTeX 3.141592-1.40.x * Ghostscript 8.x J. KNOWN PROBLEMS @@ -124,19 +129,21 @@ J. KNOWN PROBLEMS K. HISTORY ========== -2002/10/30 v1.0: First release -2002/10/30 v1.1: Option --hires added. -2002/11/04 v1.2: "nul" instead of "/dev/null" for windows. -2002/11/23 v1.3: Use of File::Spec module's "devnull" call. -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. -2008/04/05 v1.9: Options --resolution and --bbox added. +2002/10/30 v1.0: First release +2002/10/30 v1.1: Option --hires added. +2002/11/04 v1.2: "nul" instead of "/dev/null" for windows. +2002/11/23 v1.3: Use of File::Spec module's "devnull" call. +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. +2008/04/05 v1.9: Options --resolution and --bbox added. +2008/07/16 v1.10: Support for XeTeX added with new options + --pdftex, --xetex, --xetexcmds. L. TODO ======= diff --git a/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl b/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl index a13ac745439..495cbfeb1e1 100755 --- a/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl +++ b/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl @@ -22,27 +22,28 @@ $^W=1; # turn warning on # my $file = "pdfcrop.pl"; my $program = uc($&) if $file =~ /^\w+/; -my $version = "1.9"; -my $date = "2008/04/05"; +my $version = "1.10"; +my $date = "2008/07/16"; my $author = "Heiko Oberdiek"; my $copyright = "Copyright (c) 2002-2008 by $author."; # # Reqirements: Perl5, Ghostscript # History: -# 2002/10/30 v1.0: First release. -# 2002/10/30 v1.1: Option --hires added. -# 2002/11/04 v1.2: "nul" instead of "/dev/null" for windows. -# 2002/11/23 v1.3: Use of File::Spec module's "devnull" call. -# 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. -# 2008/04/05 v1.9: Options --resolution and --bbox added. -# +# 2002/10/30 v1.0: First release. +# 2002/10/30 v1.1: Option --hires added. +# 2002/11/04 v1.2: "nul" instead of "/dev/null" for windows. +# 2002/11/23 v1.3: Use of File::Spec module's "devnull" call. +# 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. +# 2008/04/05 v1.9: Options --resolution and --bbox added. +# 2008/07/16 v1.10: Support for XeTeX added with new options +# --pdftex, --xetex, and --xetexcmd. ### program identification my $title = "$program $version, $date - $copyright\n"; @@ -81,6 +82,8 @@ $::opt_debug = 0; $::opt_verbose = 0; $::opt_gscmd = $GS; $::opt_pdftexcmd = "pdftex"; +$::opt_xetexcmd = "xetex"; +$::opt_tex = "pdftex"; $::opt_margins = "0 0 0 0"; $::opt_clip = 0; $::opt_hires = 0; @@ -96,12 +99,15 @@ Options: (defaults:) --(no)verbose verbose printing ($bool[$::opt_verbose]) --(no)debug debug informations ($bool[$::opt_debug]) --gscmd call of ghostscript ($::opt_gscmd) + --pdftex | --xetex use pdfTeX | use XeTeX ($::opt_tex) --pdftexcmd call of pdfTeX ($::opt_pdftexcmd) + --xetexcmd call of XeTeX ($::opt_xetexcmd) --margins " " ($::opt_margins) add extra margins, unit is bp. If only one number is given, then it is used for all margins, in the case of two numbers they are also used for right and bottom. --(no)clip clipping support, if margins are set ($bool[$::opt_clip]) + (not available for --xetex) --(no)hires using `%%HiResBoundingBox' ($bool[$::opt_hires]) instead of `%%BoundingBox' Expert options: @@ -126,6 +132,9 @@ GetOptions( "verbose!", "gscmd=s", "pdftexcmd=s", + "xetexcmd=s", + "pdftex" => sub { $::opt_tex = 'pdftex'; }, + "xetex" => sub { $::opt_tex = 'xetex'; }, "margins=s", "clip!", "hires!", @@ -181,6 +190,10 @@ else { print "* Output file: $outputfile\n" if $::opt_debug; +if (($::opt_tex eq 'xetex') && $::opt_clip) { + die "$Error No clipping support for XeTeX!\n"; +} + ### margins my ($llx, $lly, $urx, $ury) = (0, 0, 0, 0); if ($::opt_margins =~ @@ -245,7 +258,8 @@ push @unlink_files, $tmpfile; open(TMP, ">$tmpfile") or die "$Error Cannot write tmp file `$tmpfile'!\n"; print TMP "\\def\\pdffile{$inputfile}\n"; -print TMP <<'END_TMP_HEAD'; +if ($::opt_tex eq 'pdftex') { + print TMP <<'END_TMP_HEAD'; \csname pdfmapfile\endcsname{} \def\page #1 [#2 #3 #4 #5]{% \count0=#1\relax @@ -288,6 +302,38 @@ print TMP <<'END_TMP_HEAD'; \shipout\hbox{\pdfrefxform\pdflastxform}% }% END_TMP_HEAD +} +else { # XeTeX + print TMP <<'END_TMP_HEAD'; +\expandafter\ifx\csname XeTeXpdffile\endcsname\relax + \expandafter\ifx\csname pdffile\endcsname\relax + \errmessage{XeTeX not found!}% + \else + \errmessage{XeTeX is too old!}% + \fi +\fi +\def\page #1 [#2 #3 #4 #5]{% + \count0=#1\relax + \setbox0=\hbox{% + \XeTeXpdffile "\pdffile" page #1% + }% + \pdfpagewidth=#4bp\relax + \advance\pdfpagewidth by -#2bp\relax + \pdfpageheight=#5bp\relax + \advance\pdfpageheight by -#3bp\relax + \shipout\hbox{% + \kern-1in% + \kern-#2bp% + \vbox{% + \kern-1in% + \kern#3bp% + \ht0=\pdfpageheight + \box0 % + }% + }% +} +END_TMP_HEAD +} print "* Running ghostscript for BoundingBox calculation ...\n" if $::opt_verbose; @@ -331,18 +377,27 @@ else { # child print TMP "\\csname \@\@end\\endcsname\n\\end\n"; close(TMP); -### Run pdfTeX +### Run pdfTeX/XeTeX push @unlink_files, "$tmp.log"; my $cmd; +my $texname; +if ($::opt_tex eq 'pdftex') { + $cmd = $::opt_pdftexcmd; + $texname = 'pdfTeX'; +} +else { + $cmd = $::opt_xetexcmd; + $texname = 'XeTeX'; +} if ($::opt_verbose) { - $cmd = "$::opt_pdftexcmd -interaction=nonstopmode $tmp"; + $cmd .= " -interaction=nonstopmode $tmp"; } else { - $cmd = "$::opt_pdftexcmd -interaction=batchmode $tmp"; + $cmd .= " -interaction=batchmode $tmp"; } -print "* Running pdfTeX ...\n" if $::opt_verbose; -print "* pdfTeX call: $cmd\n" if $::opt_debug; +print "* Running $texname ...\n" if $::opt_verbose; +print "* $texname call: $cmd\n" if $::opt_debug; if ($::opt_verbose) { system($cmd); } @@ -350,7 +405,7 @@ else { `$cmd`; } if ($?) { - die "$Error pdfTeX run failed!\n"; + die "$Error $texname run failed!\n"; } ### Move temp file to output -- cgit v1.2.3