ugrás a tartalomhoz

Archívum - Okt 18, 2014 - Fórum téma

Fpdf letöltés hiba!

cszlak · 2014. Okt. 18. (Szo), 14.56
HTML:
  1.  <a href="#" onClick="FromPDF('<?php  echo $partner_dat; ?>','<?php echo $array_text; ?>','<?php echo $array_text_kiir;  ?>','Partner')" name="<?php echo $partner_dat['ID']; ?>" title="PDF"><img src="img/pdf_icon.png" width="14" height="14"></a>  
  2.   
  3. <script type="text/javascript">  
  4.  function  FromPDF(data,text,text2,site){  
  5.       
  6.      $.post( 'phppdf/pdf_creator.php',{data:data,text:text,text2:text2,site:site}, function(data) {  
  7.               
  8.          if(data.length==0){      
  9.         //ok  
  10.         console.log('ok');    
  11.         }else{  
  12.             //nem ok  
  13.             console.log(data);            
  14.         }   
  15.             //return data;         
  16.        });     
  17.      }  
  18. </script>  
pdf_creator.php:
  1. require('fpdf.php');  
  2.  class PDF extends FPDF  
  3. {     
  4. // Page header  
  5. function Header(){  
  6.     // Logo  
  7.     //$this->Image('logo.png',10,6,30);  
  8.     // Arial bold 15  
  9.     $this->SetFont('Arial','B',16);       
  10.     // Title  
  11.     $this->Cell(500,20,'Site',0,0,'C');    
  12.     // Line break  
  13.     $this->Ln(40);  
  14. }  
  15. // Page footer  
  16. function Footer(){  
  17.     // Position at 1.5 cm from bottom  
  18.     $this->SetY(-15);  
  19.     // Arial italic 8  
  20.     $this->SetFont('Arial','I',12);  
  21.     // Page number  
  22.     $this->Cell(0,10,' Page '.$this->PageNo(),0,0,'C');  
  23. }     
  24. }  
  25. $pdf = new PDF('P','pt','A4');  
  26. $pdf->AddPage();  
  27. $pdf->Cell(150,20,'Data',1,0,'L');  
  28. $pdf->Output('Site2.pdf','I');  
Consloe.log kimenetnél ezt a hibát írja ki:
Some data has already been output, can't send PDF file


Vagy:
%PDF-1.3
3 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/Contents 4 0 R>>
endobj .........


Ha itt:
  1. $pdf->Output('Site2.pdf','I');  

átírom
  1. $pdf->Output('Site2.pdf','F');  

Akkor simán lementi a pdf-et a tárhelyre.