I am the author of CAM :: PDF.
Well, there are two parts. One of them is page sizes, as you noted. This works as expected: I used Apple Preview.app to rotate the PDF file and ran these two 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 also the attribute of the `/ Rotate 'page. An argument is the number of degrees (the default is 0, but 90 or 270 are not uncommon). Like page sizes, this is a property of the inherited property, so you need to go to the 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";
source share