diff options
Diffstat (limited to 'Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl')
-rwxr-xr-x | Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl | 66 |
1 files changed, 50 insertions, 16 deletions
diff --git a/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl b/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl index c96b2d92742..1fdd3ab3d8f 100755 --- a/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl +++ b/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl @@ -21,8 +21,8 @@ $^W=1; # turn warning on # my $file = "pdfcrop.pl"; my $program = uc($&) if $file =~ /^\w+/; -my $version = "1.29"; -my $date = "2010/09/06"; +my $version = "1.30"; +my $date = "2010/09/15"; my $author = "Heiko Oberdiek"; my $copyright = "Copyright (c) 2002-2010 by $author."; # @@ -88,6 +88,9 @@ my $copyright = "Copyright (c) 2002-2010 by $author."; # * Windows only: support of spaces in command # names in unrestricted mode. # 2010/09/06 v1.29: * Find the latest Ghostscript version in registry. +# 2010/09/15 v1.30: * Warning of pdfTeX because of \pdfobjcompresslevel +# avoided when reducing \pdfminorversion. +# * Fix for TeX syntax characters in input file names. ### program identification my $title = "$program $version, $date - $copyright\n"; @@ -550,7 +553,7 @@ foreach my $cmd (keys %cmd) { } else { $err = 1 if $val =~ /\.exe.*\s/i; - $err = 1 if $val =~ /\s[-\/]/; + $err = 1 if $val =~ /\s[-\/@+]/; } die "$Error Forbidden whitespace for option `--$cmd' ($val)!\n" if $err; } @@ -599,9 +602,9 @@ $SIG{'__DIE__'} = \&clean; ### Calculation of BoundingBoxes # use safe file name for use within cmd line of gs (unknown shell: space, ...) -# and pdfTeX (dollar, ...) +# and pdfTeX (hash, curly braces, ...) my $inputfilesafe = $inputfile; -if ($inputfile =~ /[\s\$~'"]/) { +if ($inputfile =~ /[\s\$~'"#{}]/) { $inputfilesafe = "$tmp-img.pdf"; push @unlink_files, $inputfilesafe; my $symlink_exists = eval { symlink("", ""); 1 }; @@ -642,17 +645,30 @@ push @unlink_files, $tmpfile; open(TMP, ">$tmpfile") or die "$Error Cannot write tmp file `$tmpfile'!\n"; print TMP <<'END_TMP'; -\catcode`\{=1 % -\catcode`\}=2 % +\catcode37 14 % percent +\catcode33 12 % exclam +\catcode34 12 % quote +\catcode35 6 % hash +\catcode39 12 % apostrophe +\catcode40 12 % left parenthesis +\catcode41 12 % right parenthesis +\catcode45 12 % minus +\catcode46 12 % period +\catcode60 12 % less +\catcode61 12 % equals +\catcode62 12 % greater +\catcode91 12 % left square +\catcode93 12 % right square +\catcode96 12 % back tick +\catcode123 1 % left curly brace +\catcode125 2 % right curly brace \catcode`\#=6 % +\escapechar=92 % END_TMP print TMP "\\def\\pdffile{$inputfilesafe}\n"; print TMP <<'END_TMP'; \def\stripprefix#1>{} -\def\onelevelsanitize#1{% - \edef#1{\expandafter\stripprefix\meaning#1}% -} -\onelevelsanitize\pdffile +\edef\pdffile{\expandafter\stripprefix\meaning\pdffile}% END_TMP if ($::opt_tex eq 'luatex') { print TMP <<'END_TMP'; @@ -679,6 +695,7 @@ if ($::opt_tex eq 'luatex') { 'pdflastximage', 'pdfrefximage', 'pdfminorversion', + 'pdfobjcompresslevel', }) tex.print('1') end @@ -697,6 +714,7 @@ if ($::opt_tex eq 'luatex') { \global\let\pdflastximage\TESTpdflastximage % \global\let\pdfrefximage\TESTpdfrefximage % \global\let\pdfminorversion\TESTpdfminorversion % + \global\let\pdfobjcompresslevel\TESTpdfobjcompresslevel % \else % \errmessage{% Missing \string\luatexversion % @@ -711,15 +729,31 @@ if ($::opt_tex eq 'pdftex' or $::opt_tex eq 'luatex') { \pdfoutput=1 % \pdfcompresslevel=9 % \csname pdfmapfile\endcsname{} +\def\IfUndefined#1#2#3{% + \begingroup\expandafter\expandafter\expandafter\endgroup + \expandafter\ifx\csname#1\endcsname\relax + #2% + \else + #3% + \fi +} \def\setpdfversion#1{% - \ifx\pdfminorversion\undefined - \ifx\pdfoptionpdfminorversion\undefined + \IfUndefined{pdfobjcompresslevel}{% + }{% + \ifnum#1<5 % + \pdfobjcompresslevel=0 % \else - \pdfoptionpdfminorversion=#1\relax + \pdfobjcompresslevel=2 % \fi - \else + }% + \IfUndefined{pdfminorversion}{% + \IfUndefined{pdfoptionpdfminorversion}{% + }{% + \pdfoptionpdfminorversion=#1\relax + }% + }{% \pdfminorversion=#1\relax - \fi + }% } \def\page #1 [#2 #3 #4 #5]{% \count0=#1\relax |