Tuesday, September 16, 2014

Anyone know how to install pdftk for CentOS?

Reference from http://wiki.centos.org/HowTos/SetupRpmBuildEnvironment
# yum install rpm-build
sudo yum install rpm-build
sudo yum install redhat-rpm-config
sudo yum install make
yum install gcc
Reference from https://www.pdflabs.com/docs/install-pdftk-on-redhat-or-centos/
sudo yum install gcc gcc-java libgcj libgcj-devel gcc-c++ 
wget https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk-2.02-src.zip 
unzip pdftk-2.02-src.zip 
cd pdftk-2.02-dist/pdftk 
make -f Makefile.Redhat 
sudo make -f Makefile.Redhat install
Upon completion, you will find pdftk in /usr/local/bin.

Reference from http://pkgs.org/centos-6/repoforge-x86_64/pdftk-1.44-1.el6.rf.x86_64.rpm.html

wget apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/pdftk-1.44-1.el6.rf.x86_64.rpm
rpm -Uvh pdftk-1.44-1.el6.rf.x86_64.rpm OR rpm -Uvh *rpm
yum install pdftk 

How to get PDF boxes information using PHP

If you want to extract Total no of pages,Creator,Creation Date,Producer,Tagged,Page size,MediaBox,CropBox,BleedBox,TrimBox,ArtBox,File size,PDF version etc then you can used below code.

$file_name = "files/client_bussinesscard_front.pdf";
echo "<b>All Details : </b>";
$command_pagesize8 = "pdfinfo -box  $file_name";
shell_exec($command_pagesize8); //run the command
echo "<br><br><hr>";

echo "<b>Total Pages : </b>";
$command_pagesize1 = "pdfinfo -box  $file_name | grep Pages";
shell_exec($command_pagesize1); //run the command
echo "<br><br><hr>";

echo "<b>Page size : </b>";
$command_pagesize2 = "pdfinfo -box  $file_name | grep 'Page size'";
shell_exec($command_pagesize2); //run the command
echo "<br><br><hr>";

$command_pagesize3 = "pdfinfo -box  $file_name | grep 'MediaBox'";
mm($command_pagesize3,"<b>MediaBox Details (wight x height):</b><br>");

$command_pagesize4 = "pdfinfo -box  $file_name | grep 'CropBox'";
mm($command_pagesize4,"<b>CropBox Details (wight x height):</b><br>");

$command_pagesize5 = "pdfinfo -box  $file_name | grep 'BleedBox'";
mm($command_pagesize5,"<b>BleedBox Details (wight x height):</b><br>");

$command_pagesize6 = "pdfinfo -box  $file_name | grep 'TrimBox'";
mm($command_pagesize6,"<b>TrimBox Details (wight x height):</b><br>");

$command_pagesize7 = "pdfinfo -box  $file_name | grep 'ArtBox'";
mm($command_pagesize7,"<b>ArtBox Details (wight x height):</b><br>");

function mm($command,$title)
    echo $title;   
    $array = explode(" ",shell_exec($command));   
    foreach($array as $val)
    <table width="50%" border="1">
            <td align="center"><?php echo $final_array[3] . " x " .$final_array[4]; ?></td>
            <td align="center"><?php echo round(($final_array[3]*0.35277777778),2) . " x " .round(($final_array[4]*0.35277777778),2);?><br>
            <?php echo round(($final_array[3]*0.35277777778)) . " x " .round(($final_array[4]*0.35277777778));?></td>
rathoddhirendra.blogspot.com-Google pagerank and Worth