[英]TCPDF ERROR: Some data has already been output to browser, can't send PDF file
the errors:错误:
-First one: Notice: Undefined offset: 0 in \html2pdf\html2pdf.class.php on line 4957 -第一个:注意:未定义的偏移量:0 in \html2pdf\html2pdf.class.php on line 4957
-2end error: Notice: Undefined offset: 0 in \html2pdf\html2pdf.class.php on line 4957 -2end 错误:注意:未定义的偏移量:0 in \html2pdf\html2pdf.class.php 在第 4957 行
-3rd error: Warning: Cannot modify header information - headers already sent by (output started at \html2pdf\html2pdf.class.php:4957) in \html2pdf_tcpdf_5.0.002\tcpdf.php on line 6122 -3rd error: Warning: Cannot modify header information - headers already sent by (output started at \html2pdf\html2pdf.class.php:4957) in \html2pdf_tcpdf_5.0.002\tcpdf.php on line 6122
I separate the code of page to make it clearly.
我将页面代码分开以使其清楚。
I'm so tired and tomorrow is the presintation day.我太累了,明天是预科日。 please help !
请帮忙 !
Head of page: first part of html2pdf页首:html2pdf的第一部分
<?php ob_start(); ?>
2end line: 2端线:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Facture</title>
</head>
Body part身体的一部分
<body>
<?php
include_once"./html2pdf/html2pdf.class.php";
include_once"Traitement.php";
session_start();
$numcom="";$datecom="";$dateliv="";
$cur=Traitement::commande($_GET['numcom'],$_SESSION['log']);
if($cur->rowCount()<>0){
while($row=$cur->fetch()){
$numcom=$row[0];
$datecom=$row[1];
$dateliv=$row[2];
}
}
$cur->closeCursor();
?>
<div style='margin:0 0 0 0;text-align:left;'>
<h3 style='margin:1% 0 0 0;display:inline-block'><span style='display:inline-block'>Client: </span><span style='display:inline-block'>".$_SESSION['log']."</span></h3>
<h3 style='margin:1% 0 0 0'><span style='display:inline-block'>Code de commande: </span><span style='display:inline-block'>".$numcom."</span></h3>
</div>
<div style='margin:0 5% 0 0;text-align:left;padding:0 0 0 2%'>
<h3 style='margin:1% 0 0 0'><span style='display:inline-block'>Date de commande: </span><span style='display:inline-block'>".$datecom."</span></h3>
<h3 style='margin:1% 0 0 0'><span style='display:inline-block'>Date de livraison: </span><span style='display:inline-'>".$dateliv."</span></h3>
</div>
<table style='margin:5% 0 0 0;border:1px solid white'>
<thead style='background:white;color:black'>
<th align='center' style=''>Article</th>
<th align='center' style=''>Quantité</th>
<th align='center' style=''>Prix unitaire</th>
<th align='center' style=''>Sous-Total</th>
</thead>
<tbody>
<?php
$cur=Traitement::achatparcommnde($_GET['numcom'],$_SESSION['log']);
if($cur->rowCount()<>0){
while($row=$cur->fetch()){
$nom=$row[0];
$prixunitaire=$row[1];
$qte=$row[2];
$soustotal=$row[1]*$row[2];
echo"<td align='center' style=''>$nom</td>
<td align='center' style=''>$qte</td>
<td align='center' style=''>$prixunitaire Dhs</td>
<td align='center' style=''>$soustotal Dhs</td>";
}
}
?>
</tbody>
</table>
<h2 id='foot' align='center' style=''>Merci pour votre achat</h2>
</body>
</html>
Bottom of page: second part of html2pdf页面底部:html2pdf的第二部分
<?php
$contents=ob_get_clean();
$pdf=new HTML2PDF("P","A4","fr");
$pdf->writeHTML($contents);
$pdf->OutPut("facture.pdf");
?>
Your "Notice: bla bla" errors are the one causing you trouble, as they're output.您的“注意:bla bla”错误是给您带来麻烦的错误,因为它们是 output。 Indeed they're not errors just warnings that can be ignored.
事实上,它们不是错误,只是可以忽略的警告。
Disable PHP Notice errors with:禁用 PHP 注意错误:
error_reporting(E_ALL & ~E_NOTICE);
at the start of your PHP ( before your require() or include() of html2pdf module).在 PHP 的开头(在您的 html2pdf 模块的 require() 或 include() 之前)。
Thank you, the error was in html part, if you look well to table you will get a 'tr' tag don't add to.谢谢,错误出现在 html 部分,如果你对表格看起来很好,你会得到一个不要添加的“tr”标签。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.