我需要在 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"