【发布时间】:2020-06-21 21:54:49
【问题描述】:
我正在尝试将此“PHP”页面转换为“PDF”页面,但我每次都会收到此消息。虽然,一切看起来都不错。
错误:
-第一个: 注意:未定义的偏移量:0 in \html2pdf\html2pdf.class.php on line 4957
-2end 错误:注意:未定义的偏移量:0 in \html2pdf\html2pdf.class.php on line 4957
-3rd 错误: 警告:无法修改标头信息 - 标头已由 \html2pdf_tcpdf_5.0.002\tcpdf.php 中的(输出开始于 \html2pdf\html2pdf.class.php:4957)发送第6122行
为了清楚起见,我把页面的代码分开了。
我太累了,明天是预科日。请帮忙!
页头:html2pdf的第一部分
<?php ob_start(); ?>
第二行:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Facture</title>
</head>
身体部位
<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>
页面底部:html2pdf的第二部分
<?php
$contents=ob_get_clean();
$pdf=new HTML2PDF("P","A4","fr");
$pdf->writeHTML($contents);
$pdf->OutPut("facture.pdf");
?>
【问题讨论】: