title: cakephp 2.1 and creating pdf
body: <p>hi all I'm trying to create an invoicing system however when i goto the related url i get a blank page and header just being the url. I've followed the following tutorial <code>[http://bakery.cakephp.org/articles/kalileo/2010/06/08/creating-pdf-files-with-cakephp-and-tcpdf]</code></p>
  
  <p>here is my viewPdf function in the invoices controller</p>
  
  <pre><code>    function viewPdf($id = null) 
      { 
          if (!$id) 
          { 
              $this-&gt;Session-&gt;setFlash('Sorry, there was no property ID submitted.'); 
              $this-&gt;redirect(array('action'=&gt;'index_admin'), null, true); 
          } 
          Configure::write('debug',0); // Otherwise we cannot use this method while developing 
  
          $id = intval($id); 
  
          $property = $this-&gt;__view($id); // here the data is pulled from the database and set for the view 
  
          if (empty($property)) 
          { 
              $this-&gt;Session-&gt;setFlash('Sorry, there is no property with the submitted ID.'); 
              $this-&gt;redirect(array('action'=&gt;'index'), null, true); 
          } 
  
          $this-&gt;layout = 'pdf'; //this will use the pdf.ctp layout 
          $this-&gt;render(); 
      } 
  
  //End of Controller
  }
  </code></pre>
  
  <p>and here is my viewPdf view </p>
  
  <pre><code>&lt;?php 
  App::import('Vendor','xtcpdf');  
  $tcpdf = new XTCPDF(); 
  $textfont = 'freesans'; // looks better, finer, and more condensed than 'dejavusans' 
  $fpdf-&gt;xheadertext = 'YOUR ORGANIZATION';
  $tcpdf-&gt;SetAuthor("KBS Homes &amp; Properties at http://kbs-properties.com"); 
  $tcpdf-&gt;SetAutoPageBreak( false ); 
  $tcpdf-&gt;setHeaderFont(array($textfont,'',40)); 
  $tcpdf-&gt;xheadercolor = array(150,0,0); 
  $tcpdf-&gt;xheadertext = 'KBS Homes &amp; Properties'; 
  $tcpdf-&gt;xfootertext = 'Copyright Â© %d KBS Homes &amp; Properties. All rights reserved.'; 
  
  // add a page (required with recent versions of tcpdf) 
  $tcpdf-&gt;AddPage(); 
  
  // Now you position and print your page content 
  // example:  
  $tcpdf-&gt;SetTextColor(0, 0, 0); 
  $tcpdf-&gt;SetFont($textfont,'B',20); 
  $tcpdf-&gt;Cell(0,14, "Hello World", 0,1,'L'); 
  // ... 
  // etc. 
  // see the TCPDF examples  
  
  echo $tcpdf-&gt;Output('filename.pdf', 'D'); 
  
  ?&gt;
  </code></pre>
  
  <p>to my knowledge it should be creating a pdf file that has the words 'hello world' written in it.</p>
  
  <p>after following advice about that being outdated, I used the link to github and have this in my controller now </p>
  
  <pre><code> public function view($id = null) {
      $this-&gt;set('title_for_layout', 'Invoices');
      $this-&gt;set('stylesheet_used', 'homestyle');
      $this-&gt;set('image_used', 'eBOXLogoHome.png');
      $this-&gt;layout='home_layout';
              $this-&gt;Invoice-&gt;id = $id;
              if (!$this-&gt;Invoice-&gt;exists()) {
                  throw new NotFoundException(__('Invalid invoice'));
              }
              $this-&gt;pdfConfig = array(
                  'orientation' =&gt; 'potrait',
                  'filename' =&gt; 'Invoice_' . $id
              );
  
              $this-&gt;set('invoice', $this-&gt;Invoice-&gt;read(null, $id));
  
          }
      }
  </code></pre>
  
  <p>and my view.ctp</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;body&gt;
  &lt;?php $this-&gt;pdfConfig = array('engine' =&gt; 'CakePdf.WkHtmlToPdf') ?&gt;
  &lt;?php echo $invoice; ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>it prints out Array but does not render it as a pdf file </p>
  
  <p>here is a link to the github pagw</p>
  
  <p><a href="https://github.com/ceeram/CakePdf" rel="nofollow">https://github.com/ceeram/CakePdf</a></p>