pdfcrop does not work
Perhaps there is a problem with redirection of standard/error output with your Perl version. Try updating. The current version is 5.16.1.1601.
Also I have written a test script that tries different execution methods with and without redirecting:
#!/usr/bin/env perl
use strict;
$^W=1;
use File::Spec::Functions qw(devnull);
my $null = devnull();
my $prg = '"C:\Program Files\gs\gs9.06\bin\gswin64c.exe"';
# $prg = '"C:\Program Files\gs\gs9.05\bin\gswin32c.exe"';
my $testfile = 'Instructions-autopp.pdf';
# $testfile = 'test.pdf';
my $cmdline =
"$prg -sDEVICE=bbox -dBATCH -dNOPAUSE -c save pop -f $testfile";
sub analyze {
if ($? == -1) { print "! Execution error: $!/$^E\n"; }
elsif ($? & 127) { print sprintf "! Signal: %d\n", $? & 127; }
elsif ($? != 0) { print sprintf "! Exit code: %d\n", $? >> 8; }
else { print "* No error.\n"; }
}
sub test {
print "\n*** system() ***\n";
system($cmdline);
analyze();
print "\n*** backticks ***\n";
my $result = `$cmdline`;
analyze();
print "==========\n";
print $result;
print "==========\n";
print "\n*** pipe ***\n";
my $ret = open(IN, "$cmdline |");
if ($ret) {
while (<IN>) {
chomp;
print "[[$_]]\n";
}
close(IN);
analyze();
}
else {
print "! Error: Execution error: $!/$^E\n";
}
}
test();
print "\n*** with stderror redirection ***\n";
$cmdline .= " 2>&1";
test();
print "\n*** with stderror and stdout redirection ***\n";
$cmdline .= " 1>$null";
test();
1;
__END__
The result (example with win32/ActivePerl 16.0.1):
*** system() ***
GPL Ghostscript 9.05 (2012-02-08)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 2.
Page 1
%%BoundingBox: 72 696 341 767
%%HiResBoundingBox: 72.287998 696.401979 340.685990 766.925977
Page 2
%%BoundingBox: 72 95 321 770
%%HiResBoundingBox: 72.503998 95.147997 320.093990 769.985977
* No error.
*** backticks ***
%%BoundingBox: 72 696 341 767
%%HiResBoundingBox: 72.287998 696.401979 340.685990 766.925977
%%BoundingBox: 72 95 321 770
%%HiResBoundingBox: 72.503998 95.147997 320.093990 769.985977
* No error.
==========
GPL Ghostscript 9.05 (2012-02-08)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 2.
Page 1
Page 2
==========
*** pipe ***
[[GPL Ghostscript 9.05 (2012-02-08)]]
[[Copyright (C) 2010 Artifex Software, Inc. All rights reserved.]]
[[This software comes with NO WARRANTY: see the file PUBLIC for details.]]
[[Processing pages 1 through 2.]]
[[Page 1]]
%%BoundingBox: 72 696 341 767
%%HiResBoundingBox: 72.287998 696.401979 340.685990 766.925977
[[Page 2]]
%%BoundingBox: 72 95 321 770
%%HiResBoundingBox: 72.503998 95.147997 320.093990 769.985977
* No error.
*** with stderror redirection ***
*** system() ***
GPL Ghostscript 9.05 (2012-02-08)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 2.
Page 1
%%BoundingBox: 72 696 341 767
%%HiResBoundingBox: 72.287998 696.401979 340.685990 766.925977
Page 2
%%BoundingBox: 72 95 321 770
%%HiResBoundingBox: 72.503998 95.147997 320.093990 769.985977
* No error.
*** backticks ***
* No error.
==========
GPL Ghostscript 9.05 (2012-02-08)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 2.
Page 1
%%BoundingBox: 72 696 341 767
%%HiResBoundingBox: 72.287998 696.401979 340.685990 766.925977
Page 2
%%BoundingBox: 72 95 321 770
%%HiResBoundingBox: 72.503998 95.147997 320.093990 769.985977
==========
*** pipe ***
[[GPL Ghostscript 9.05 (2012-02-08)]]
[[Copyright (C) 2010 Artifex Software, Inc. All rights reserved.]]
[[This software comes with NO WARRANTY: see the file PUBLIC for details.]]
[[Processing pages 1 through 2.]]
[[Page 1]]
[[%%BoundingBox: 72 696 341 767]]
[[%%HiResBoundingBox: 72.287998 696.401979 340.685990 766.925977]]
[[Page 2]]
[[%%BoundingBox: 72 95 321 770]]
[[%%HiResBoundingBox: 72.503998 95.147997 320.093990 769.985977]]
* No error.
*** with stderror and stdout redirection ***
*** system() ***
%%BoundingBox: 72 696 341 767
%%HiResBoundingBox: 72.287998 696.401979 340.685990 766.925977
%%BoundingBox: 72 95 321 770
%%HiResBoundingBox: 72.503998 95.147997 320.093990 769.985977
* No error.
*** backticks ***
* No error.
==========
%%BoundingBox: 72 696 341 767
%%HiResBoundingBox: 72.287998 696.401979 340.685990 766.925977
%%BoundingBox: 72 95 321 770
%%HiResBoundingBox: 72.503998 95.147997 320.093990 769.985977
==========
*** pipe ***
[[%%BoundingBox: 72 696 341 767]]
[[%%HiResBoundingBox: 72.287998 696.401979 340.685990 766.925977]]
[[%%BoundingBox: 72 95 321 770]]
[[%%HiResBoundingBox: 72.503998 95.147997 320.093990 769.985977]]
* No error.