简体   繁体   English

TCPDF ERROR: Some data has been output to browser, can't send PDF file

[英]TCPDF ERROR: Some data has already been output to browser, can't send PDF file

i'm trying to convert this 'PHP' page to 'PDF' page but i toke this message everytime.我正在尝试将此“PHP”页面转换为“PDF”页面,但我每次都会收到此消息。 Although, everything is looks right.虽然,一切看起来都不错。

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.

相关问题 TCPDF &amp; mPDF 错误:部分数据已经输出到浏览器,无法发送PDF文件 - TCPDF & mPDF error: Some data has already been output to browser, can't send PDF file TCPDF ERROR:部分数据已经输出,无法发送PDF文件 - TCPDF ERROR: Some data has already been output, can't send PDF file 获取TCPDF:一些数据已经输出,无法在Laravel 4中发送PDF文件 - Getting TCPDF:Some data has already been output, can't send PDF file in Laravel 4 TCPDF错误:已经输出了一些数据,尝试将数据放入视图时无法发送PDF文件 - TCPDF ERROR: Some data has already been output, can't send PDF file while trying to put data in view mPDF错误:部分数据已经输出到浏览器,无法发送PDF文件 - mPDF error: Some data has already been output to browser, can't send PDF file cakephp tcpd错误:一些数据已经输出到浏览器,无法在远程服务器上发送PDF文件 - cakephp tcpd error: Some data has already been output to browser, can't send PDF file on remote server 使用FPDF致命错误:有些数据已经输出,无法发送PDF文件? - Fatal error using FPDF:Some data has already been output, can't send PDF file? FPDF 错误:部分数据已经输出。 无法发送 PDF 文件 - FPDF error: some data has already been output. Can't send PDF file FPDF错误:已经输出了一些数据,无法发送PDF文件 - FPDF error: Some data has already been output, can't send PDF file magento FPDF错误:已经输出了一些数据,无法发送PDF文件 - magento FPDF error: Some data has already been output, can't send PDF file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM