title: Symfony2 - Generate a PDF with HTML2PDF
body: <p>I'm a new user in Symfony2, I would like to generate a PDF and I don't succeess to create a correct PDF with <a href="http://html2pdf.fr/en/default" rel="nofollow">HTML2PDF</a>. In fact, I have a pdf with 1 page containing a junk string like this : "HTTP/1.0 200 OK Cache-Control: no-cache Date: Mon, 11 Mar 2013 19:37:29 GMT" and I have some additional line-break... </p>
  
  <p>I would like to know if my method to generate a pdf is correct, that is return a php template who generate the pdf using HTML2PDF. </p>
  
  <p>Here my controller code :</p>
  
  <pre><code>public function exec_cuAction($id)
  {
  //CU 4 : imprimer toutes les factures
  switch ($id){
      case 2: 
          $infos = null;
          $html= $this-&gt;render('PeriscopeAdminBundle:Admin:FactureVide.html.twig',array('infos'=&gt; $infos)); //les content pour le pdf
          $name = 'factureVide.pdf';                      
          return $this-&gt;render('PeriscopeAdminBundle:Admin:afficher_factures_pdf.html.php', array('name'=&gt;$name, 'html'=&gt;$html));
          break;
  }
  </code></pre>
  
  <p>Here my PDF content :</p>
  
  <pre><code>&lt;page orientation="portrait" format="A4" style="font-size: 18px"&gt;
     &lt;div id="wrapper"&gt;
              &lt;div id="left_informations"&gt;
  
  
                  &lt;br&gt;&lt;br&gt;&lt;br&gt;
  
                  &lt;div id="fields"&gt;
                      &lt;div id="invoice_id"&gt;
                          &lt;span&gt;Facture n____ &lt;/span&gt;
                          &lt;span&gt;____________&lt;/span&gt;
                          &lt;span&gt;Date : ___/___/______&lt;/span&gt;
                      &lt;/div&gt;&lt;br&gt;
                      &lt;div&gt;Nom de l'enfant :&lt;/div&gt;&lt;br&gt;
                      &lt;div&gt;Primaire/Maternelle : &lt;/div&gt;&lt;br&gt;
                      &lt;div&gt;Date de naissance : &lt;/div&gt;&lt;br&gt;
                      &lt;div&gt;Classe : &lt;/div&gt;&lt;br&gt;
                      &lt;div&gt;Enseignant : &lt;/div&gt;&lt;br&gt;
                      &lt;div&gt;Taux horaire :&lt;/div&gt;&lt;br&gt;
                      &lt;div&gt;Heures matin : &lt;/div&gt;&lt;br&gt;
                      &lt;div&gt;Heures soir : &lt;/div&gt;&lt;br&gt;
                      &lt;div&gt;Total heures : &lt;/div&gt;
                      &lt;h4&gt;Net  payer du mois : &lt;/h4&gt;
                      &lt;br&gt;
                      &lt;div&gt;Votre retard  la fin du mois precédent : &lt;/div&gt;&lt;br&gt;
                      &lt;h4&gt;RETARD : &lt;/h4&gt;
                      &lt;div&gt;Votre situation nette : &lt;/div&gt;
                      &lt;br&gt;
                      &lt;div&gt; Association loi 1901, SIRET 39217524600017    Code APE 913 E &lt;br&gt;
                            Exonr de TVA Article 261 du CGI
                      &lt;/div&gt;
                      &lt;div&gt;&lt;i&gt;Partie  conserver&lt;/i&gt;&lt;/div&gt;
                      &lt;div style="width:610px;"&gt;---------------------------------------------------------------------------------------------------------&lt;/div&gt;
                      &lt;br&gt;
                      &lt;div id="invoice_id"&gt;
                          &lt;span&gt;Facture n____ &lt;/span&gt;
                          &lt;span&gt;____________&lt;/span&gt;
                          &lt;span&gt;Date: __/__/_____&lt;/span&gt;
                      &lt;/div&gt;
                      &lt;div&gt;Nom de l'enfant :&lt;/div&gt;
                      &lt;br&gt;
                      &lt;div&gt;Votre situation nette : &lt;/div&gt;
                      &lt;br&gt;
                      &lt;div&gt;Payer en espce la somme de :&lt;/div&gt;
                      &lt;br&gt;
                      &lt;div&gt;Payer par chque  l'ordre de Priscope n&lt;/div&gt;
                      &lt;div style="margin-left:100px;"&gt;Banque : &lt;/div&gt;
                      &lt;div style="margin-left:100px;"&gt;Somme : &lt;/div&gt;
                      &lt;br&gt;&lt;br&gt;
                      &lt;div style="margin-left:100px;"&gt; 
                          &lt;span&gt;&lt;u&gt;Date:&lt;/u&gt; ___/___/______&lt;/span&gt;
                          &lt;span&gt;&lt;u&gt;Signature :&lt;/u&gt; &lt;/span&gt;
                      &lt;/div&gt;
                      &lt;br&gt;&lt;br&gt;&lt;br&gt;
  
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div id="right_ads"&gt;
              &lt;/div&gt;
  
  
     &lt;/div&gt; 
  &lt;/page&gt;
  </code></pre>
  
  <p>And my template, the return of my controller :</p>
  
  <pre><code>&lt;?php       
      ob_start();
      try
      {
          $html2pdf = new \Html2Pdf_Html2Pdf('P', 'A4', 'fr');
          $html2pdf-&gt;pdf-&gt;SetDisplayMode('fullpage');
              $html2pdf-&gt;writeHTML($html);
          $html2pdf-&gt;Output($name);
              exit;
      }
      catch(HTML2PDF_exception $e) {
          echo $e;
          exit;
      }
  </code></pre>