Php 一些数据已经输出到TCPDF
我正在使用TCPDF库生成PDF,我的代码是Php 一些数据已经输出到TCPDF,php,pdf,tcpdf,Php,Pdf,Tcpdf,我正在使用TCPDF库生成PDF,我的代码是 include("tcpdf/tcpdf.php"); $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 001');
include("tcpdf/tcpdf.php");
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 001');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));
$pdf->setFooterData(array(0,64,0), array(0,64,128));
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->setFontSubsetting(true);
$pdf->SetFont('dejavusans', '', 14, '', true);
$pdf->AddPage();
$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));
$html = "Muhammad Shoaib";
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->Output('example_001.pdf', 'I');
它工作正常,但是当我添加HTML
代码时,它会给我错误,我的HTML
代码是
$html = '<table>';
$html .= '<tr>';
$html .= '<td>';
$html .= 'Test';
$html .= '/<td>';
$html .= '</tr>';
$html .= '</table>';
我找到了几个链接,但不了解问题所在
尝试添加ob_clean();和ob_start()
ob\u clean()
和ob\u end\u clean()
对我也不起作用。主要问题是我的html代码不起作用。那你为什么不尝试回显你的html,看看有什么问题?放置“$pdf->writeHTML($html,true,false,true,false)”;”在注释和添加echo('html')<代码>html正常,现在可以工作了。
TCPDF ERROR: Some data has already been output, can't send PDF file