title: PHP Get height and width in Pdf file proprieties
body: <p>I have a PDF file.
  I would to get it height and width in mm.</p>
  
  <p>So I do an exec(pdfinfo ... );
  I have this result :</p>
  
  <blockquote>
    <p>Creator: Adobe InDesign CS5 (7.0.3) Producer: Acrobat Distiller 9.4.2 (Macintosh) CreationDate: Mon Jan 30 15:48:43 2012 ModDate: Fri Feb 10 10:35:05 2012 Tagged: no Pages: 34 Encrypted: no Page size: 552.744 x 708.643 pts File size: 80724791 bytes Optimized: yes PDF version: 1.3 </p>
  </blockquote>
  
  <p>I have a script witch extract my info :</p>
  
  <pre><code>&lt;?php 
  $output = shell_exec("pdfinfo ".$pdflivrelink);
  $data = explode("\n", $output); //puts it into an array
  for($c=0; $c &lt; count($data); $c++) {
          if(stristr($data[$c],"Pages") == true) {
          $pagesnumber = trim(substr($data[$c],6));
          }
          if(stristr($data[$c],"Page size") == true) {
              $pagesize_H = height_pdf(trim(substr($data[$c],9)));
          }
          if(stristr($data[$c],"Page size") == true) {
              $pagesize_L = width_pdf(trim(substr($data[$c],9)));
          }
  
  }
  function height_pdf($size){
  $hauteur = round(substr($size,7,7)/2.83);
  return $hauteur;
  }
  function width_pdf($size){
  $largeur = round(substr($size,17,7)/2.83);
  return $largeur;
  } ?&gt;
  </code></pre>
  
  <p>It's OK, because I have three numbers dot three numbers (552.744 x 708.643).
  But, I don't know why, some PDF files have this info :</p>
  
  <blockquote>
    <p>Creator: pdftk 1.41 - www.pdftk.com Producer: iText 2.1.5 (by lowagie.com) CreationDate: Mon Feb 27 13:18:23 2012 ModDate: Mon Feb 27 16:26:12 2012 Tagged: no Pages: 36 Encrypted: no Page size: 425.2 x 538.582 pts File size: 5097597 bytes Optimized: yes PDF version: 1.6</p>
  </blockquote>
  
  <p>425.2 x 538.582 : So my script doesn't work!</p>
  
  <p>Can you help me? thank a lot!</p>
  
  <hr>
  
  <p>I test this :</p>
  
  <pre><code>    $output = shell_exec("pdfinfo ".$pdflivrelink);
      $data = explode("\n", $output); //puts it into an array
      for($c=0; $c &lt; count($data); $c++) {
              if(stristr($data[$c],"Pages") == true) {
              $pagesnumber = trim(substr($data[$c],6));
  
              }
              if(stristr($data[$c],"Page size") == true) {
                  echo $data[$c];
      preg_match('/Page size: ([0-9]*\.?[0-9]?) x ([0-9]*\.?[0-9]?)/', $data[$c], $matchess);
      $width = round($matchess[1]/2.83);
      $height = round($matchess[2]/2.83);
  
              }
  }
  echo "width = $width&lt;br&gt;height = $height";
  </code></pre>
  
  <p>it result : </p>
  
  <blockquote>
    <p>Page size: 425.2 x 538.582 ptswidth = 0 height = 0</p>
  </blockquote>