#!/usr/bin/perl
if($#ARGV ne 5){
  print "TO CHANGE the bounding box\n";
  print "USAGE: chnbb.pl xl yl xu yu infile.pdf outfile.pdf\n";
}else{
$infile = $ARGV[4];
open(Lista,"<$infile")||die "Can't open the file";
$outfile = $ARGV[5];
open(OUT,">$outfile")||die "Can't open the file";
#
##################################
#a
$count = 0;
@listind = <Lista>;
 select(OUT);
 for $i (@listind){
  $ll = length($i);
  $count += $ll;
 $i =~ s/MediaBox \[[^\]]*\]/MediaBox \[$ARGV[0] $ARGV[1] $ARGV[2] $ARGV[3]\]/;
  if(length($i) < $ll){
  $i = $i." " x ($ll - length($i));}
  print $i;
 }
close(Lista);
close(OUT);
}

