python - Get the existing margin on a pdf page -
i need existing margins(left, right, top, bottom) on page of pdf file in perl, here code dimension of padf page.
!/usr/bin/perl
use strict; use warnings; use cam::pdf; $pdf = cam::pdf->new('test2.pdf'); $num_page=$pdf->numpages(); print "total pages : $num_page\n"; ($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 : $width x $height inch \n"
a pdf file not word document, cannot change "margins" , have text reflow new size. more image snapshot (i.e. tiff file) of rendered document has been formatted , laid out on page. there no concept of "margin" setting in pdf. @ point it's blank page bunch of objects placed on it. happens most of objects contained within large box defined margins when page laid out.
you approximate margins looking @ bounding box of every object on page, you'd have ignore stuff outside "margins", such page headers/footers , page number, margin notes, etc.
Comments
Post a Comment