title: Why does fpdi crop the pdf page?
body: <p>So, I'm using <code>fpdi</code>, version 1.2 to add some little mark to every page in my document. Here is my code:</p>
  
  <pre><code>public static function markPdf($file, $text){
      define('FPDF_FONTPATH','font/');
      require_once('fpdi/fpdf.php');
      require_once('fpdi/fpdi.php');
      try{
          $pdf = new FPDI();
          $pagecount = $pdf-&gt;setSourceFile($file);
          for($i = 1 ; $i &lt;= $pagecount ; $i++){
              $tpl  = $pdf-&gt;importPage($i);
              $size = $pdf-&gt;getTemplateSize($tpl);
  
              // Here you can see that I'm setting orientation for every single page,
              // depending on the orientation of the original page
              $orientation = $size['h'] &gt; $size['w'] ? 'P':'L';
              $pdf-&gt;AddPage($orientation);
              $pdf-&gt;useTemplate($tpl);
  
              $pdf-&gt;SetXY(5, 5);
              $pdf-&gt;SetTextColor(150);
              $pdf-&gt;SetFont('Arial','',8);
              $pdf-&gt;Cell(0,0,$text,0,1,'R');
          }
          $pdf-&gt;Output($file, "F");
      }catch(Exception $e){
          Logger::log("Exception during marking occurred");
          return false;
      }
      return true;
  }
  </code></pre>
  
  <p>And everything works just fine, except for one little issue: when I have a document with first page in landscape orientation, all pages in generated document are cropped from the bottom and right (if the first page is in portrait mode, everything goes just fine, even if following pages are in landscape mode).
  The question is obvious: what's wrong with this function?</p>