Hi, I'm the author of CAM::PDF.
Well, there's two parts to this. One is the page's dimensions, as you noted. That works as expected: I used Apple's Preview.app to rotate a PDF file and ran these two command lines:
perl -MCAM::PDF -le'print "@{[CAM::PDF->new(shift)->getPageDimensions(1)]}"' orig.pdf
0 0 612 792
perl -MCAM::PDF -le'print "@{[CAM::PDF->new(shift)->getPageDimensions(1)]}"' rotated.pdf
0 0 792 612
But there's also the `/Rotate' page attribute. The argument is a number of degrees (default 0, but 90 or 270 are not uncommon). Like page dimensions, it's an inheritable property so you have to navigate to parent pages. Here's a quick-and-dirty command line tool to output the rotation value:
use CAM::PDF;
my $filename = shift || die;
my $pagenum = shift || die;
my $pdf = CAM::PDF->new($filename) || die;
my $pagedict = $pdf->getPage($pagenum);
my $rotate = 0;
while ($pagedict) {
$rotate = $pdf->getValue($pagedict->{Rotate});
if (defined $rotate) {
last;
}
my $parent = $pagedict->{Parent};
$pagedict = $parent && $pdf->getValue($parent);
}
print "/Rotate $rotate\n";