2010-08-20 54 views
2

當我試圖創建PDF文件時我收到以下錯誤?
我不知道爲什麼,我不知道如何解決它? 錯誤是類似於下面
`使用FPDF致命錯誤:有些數據已經輸出,無法發送PDF文件?

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\phpexample\createpdf.php:1) in C:\xampp\htdocs\phpexample\fpdf16\fpdf.php on line 1017`<br/> 
`FPDF error: Some data has already been output, can't send PDF file`<br/> 

我的編碼是這樣

<?php 
include_once('fpdf16/fpdf.php');$pdf=new FPDF(); 

$pdf->AddPage(); 
$reportdate = date('d-m-Y H:i:s'); 
$filename = $reportdate.'_report.pdf'; 
$pdf->SetFillColor(255,0,0); 
$pdf->SetTextColor(255); 
$pdf->SetDrawColor(128,0,0); 
$pdf->SetLineWidth(.3); 
$pdf->SetFont('Arial', 'B', 6); 
// Header 
$header=array('Member Card No','Full Name','Description', 'Start Date', 'Expiry Date', 'ramount', 'Address1', 'Address2'); 
$w = array(25, 35, 35, 15, 18, 15, 30, 30); 
for($i=0;$i<count($header); $i++) 
     $pdf->Cell($w[$i],7, $header[$i], 1, 0, 'L', true); 

$pdf->Ln(); 

// Reset colour set for data 
$pdf->SetFillColor(224,235,255); 
$pdf->SetTextColor(0); 
$pdf->SetFont('courier','',7); 
$fill=false; 
$resultcount=8; 
for($i=0;$i<$resultcount;$i++) 
{ 
     $height =6; 
     $pdf->Cell($w[0], '$height', 'CardNoishai', '1', '0', 'L', $fill); 
     $pdf->Cell($w[1], '$height', 'Vinoth', '1', '0', 'L', $fill); 
     $pdf->Cell($w[2], '$height', 'Sample PDF', '1', '0', 'L', $fill); 
     $pdf->Cell($w[3], '$height', date('m-d-y'), '1', '0', 'L', $fill); 
     $pdf->Cell($w[4], '$height', date('m-d-y'), '1', '0', 'L', $fill); 
     $pdf->Cell($w[5], '$height', 'test', '1', '0', 'L', $fill); 
     $pdf->Cell($w[5], '$height', 'test', '1', '0', 'L', $fill); 
     $pdf->Cell($w[5], '$height', 'Add2', '1', '0', 'L', $fill); 
     $pdf->Ln(); 
     $fill = !$fill; 

}  
$pdf->Cell(array_sum($w),0,'','T'); 
$pdf->Output($filename, 'I'); 
?> 
+0

也許你也許必須從utf-8改爲ansi – AboSami 2011-12-22 13:00:29

回答

11

開幕PHP標籤之前刪除空格。

5

您有<?php之前的空間。在PHP代碼運行之前將其刪除,因爲它會導致它被輸出。

+0

@Davide Gualano,@ Artefacto如何將圖像添加到此PDF以及如何爲不同的行設置不同的字體。例如,在第一行中,我想使它大膽而且第二次我想以粗體斜體。這是可能的嗎? – svk 2010-08-20 11:01:00

+0

@vino,如果你想問一個新的問題,開始一個新的問題。 – 2010-08-20 11:03:06

+0

@Mike Sherov無需啓動新的線程我得到了答案。它在FPDF教程中可用。感謝大家 – svk 2010-08-20 11:18:50

相關問題