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:


 <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>

<script type="text/javascript">
 function  FromPDF(data,text,text2,site){
	
	 $.post( 'phppdf/pdf_creator.php',{data:data,text:text,text2:text2,site:site}, function(data) {
      		
		 if(data.length==0){	
		//ok
		console.log('ok');	
		}else{
			//nem ok
			console.log(data);			
		} 
			//return data;		 
       });	 
	 }
</script>
pdf_creator.php:


require('fpdf.php');
 class PDF extends FPDF
{	
// Page header
function Header(){
    // Logo
    //$this->Image('logo.png',10,6,30);
    // Arial bold 15
    $this->SetFont('Arial','B',16);     
    // Title
    $this->Cell(500,20,'Site',0,0,'C');	
    // Line break
    $this->Ln(40);
}
// Page footer
function Footer(){
    // Position at 1.5 cm from bottom
    $this->SetY(-15);
    // Arial italic 8
    $this->SetFont('Arial','I',12);
    // Page number
    $this->Cell(0,10,' Page '.$this->PageNo(),0,0,'C');
}	
}
$pdf = new PDF('P','pt','A4');
$pdf->AddPage();
$pdf->Cell(150,20,'Data',1,0,'L');
$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:
$pdf->Output('Site2.pdf','I');

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

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