title: PHP pdf creation downloads pdf as corrupt
body: <p>I have a piece of code that creates a correct pdf on the server, but when I try to download it it, it downloads as corrupt:</p>
  
  <pre><code>for($i = 0 ; $i &lt; $num_tokens ; $i++){
  
      #$tokens[$i] = pronto_aes_decrypt( $token_crypt[$i] , $prontoKey );
      $tokens[$i] = pronto_aes_decrypt( $token_crypt[$i] , $prontoKey );
  
      $pdf-&gt;AddPage();
      $pdf-&gt;SetFont('Arial','B',16);
      $pdf-&gt;Cell(40,10,$tokens[$i]);
  
  
  }
  unlink("tokens.pdf");
  $pdf-&gt;Output('tokens.pdf','F');  
  
  header('Content-Type: text/csv');
  header('Content-Disposition: attachment; filename="tokens.pdf"');
  </code></pre>
  
  <p>EDIT:
  Here is how the code looks now with correct content-type and correct Output function placement:</p>
  
  <pre><code>$pdf = new FPDF( ); 
  
  for($i = 0 ; $i &lt; $num_tokens ; $i++){
  
      $tokens[$i] = pronto_aes_decrypt( $token_crypt[$i] , $prontoKey );
  
      $pdf-&gt;AddPage();
      $pdf-&gt;SetFont('Arial','B',16);
      $pdf-&gt;Cell(40,10,$tokens[$i]);
  
  }
  unlink("tokens.pdf");
  
  header('Content-Type: application/pdf');
  header('Content-Disposition: attachment; filename="tokens.pdf"');
  $pdf-&gt;Output('tokens.pdf','F');
  </code></pre>
  
  <p>The error still persists though.</p>