Perlでpdfファイルのページにある既存の余白(左、右、上、下)を取得する必要があります.padfページの寸法を取得するコードは次のとおりです.
!/usr/bin/perl
use strict;
use warnings;
use CAM::PDF;
my $pdf = CAM::PDF->new('test2.pdf');
my $num_page=$pdf->numPages();
print "Total Pages : $num_page\n";
my ($x,$y,$width,$height)=$pdf->getPageDimensions(2);
print "Dimension of PDF File : $width x $height px \n";
$width=sprintf("%.2f",$width/72); # PPI/DPI Conversion (72 px = 1 inch)
$height=sprintf("%.2f",$height/72);
print "Dimension of PDF File is : $width x $height inch \n"