在TCPDF html表中获取二维条码

问题描述

我正在尝试在HTML表中获取2D条形码(QR)。我得到以下代码

$style = array(
    
    'vpadding' => 'auto','hpadding' => 'auto','fgcolor' => array(0,0),'bgcolor' => false,//array(255,255,255)
    'module_width' => 1,// width of a single module in points
    'module_height' => 1 // height of a single module in points
);

$pdf->write2DBarcode('http://localhost/VERP/logistics/view_warehouse.PHP?id='.$warehouse->wa_id.'','QRCODE,L',20,30,50,$style,'N');

// Set some content to print
$html = <<<EOD
<table border =".5" style="line-height:20px; width:100%;">
<tr>
<td style="height:490px">test</td>
</tr>
</table>
<table border =".5" style="line-height:20px; width:100%;">
<tr>
<td style="height:490px">test</td>
</tr>
</table>
EOD;

// Print text using writeHTMLCell()
$pdf->writeHTMLCell(0,'',$html,1,true,true);

目标是在html表中获取QR码。

我从TCPDF尝试了示例49,但是我始终通过仅将包含文件名从'tcpdf_include.PHP'更改为'tcpdf.PHP'而得到错误消息:

“ TCPDF错误:某些数据已经输出,无法发送PDF文件

解决方法

找到了答案。正在寻找错误的事物。回答: TCPDF ERROR: Some data has already been output,can't send PDF file

使用TCPDF中的示例49并添加 ob_end_clean(); 在输出之前。