Cant change mediabox on existing PDF

"duder60" <duder60-/[email protected]> Fri, 12 Oct 2007 14:51:24 -0000
Newsgroups gmane.comp.lang.perl.modules.pdfapi2
Message-ID <[email protected]>
I have a bunch of PDFs wirh crop and registration marks on them. I
want to crop them, so that the marks are gone forever. I can change
the cropbox, but I can't get the mediabox to change.

Maybe I am doing things in the wrong order?

Here is my code:

use PDF::API2;

use constant in => 1/72;

$pdf_path = "c:/cf/utils/old.pdf";
$new_pdf_path = "c:/cf/utils/new.pdf";

$pdf = PDF::API2->new;
$import = PDF::API2->open("$pdf_path");
$pdf->importpage($import);
$pdf->mediabox(.5/in, .5/in, 6/in, 9/in);
$pdf->cropbox(.5/in, .5/in, 6/in, 9/in);
$pdf->saveas("$new_pdf_path");

Thanks!