RGBA 颜色在 TCPDF 表中不能用作内联 CSS


rgba color does not working as inline css in tcpdf table

我正在集成tcpdf以生成pdf。我在 pdf 中没有出现背景颜色的问题。我正在为背景颜色表格行使用 rgba 颜色代码。

网页代码:

<table>
<tr>
<td>ID</td>
<td>Name</td>
<td>Mark</td>
</tr>
<tr>
<td>1</td>
<td>test</td>
<td style="background-color:rgba(0, 255, 0, 1) none repeat scroll 0 0">100<td/>
</tr>
<tr>
<td>2</td>
<td>test2</td>
<td style="background-color:rgba(0, 255, 0, 0.85) none repeat scroll 0 0">66<td/>
</tr>
<tr>
<td>3</td>
<td>test3</td>
<td style="background-color:rgba(0, 255, 0, 0.22) none repeat scroll 0 0">45<td/>
</tr>
<tr>
<td>4</td>
<td>test4</td>
<td style="background-color:rgba(0, 255, 0, 0.08) none repeat scroll 0 0">12<td/>
</tr>
</table>

PHP代码

$pdf->writeHTMLCell(200, '', '50', '40', $html, 0, 1, 1, true, 'C', true);

如果 TCPpdf 不支持 RGBA 代码。如何将 rgba 转换为相应值的 html 颜色代码。请指导我。我期待您的回复。

TCPDF将不支持正常的html style属性。 您必须添加以下行才能设置 BG 颜色。

$pdf->SetFillColor(0,255,0);

用于设置不透明度尝试

$pdf->SetAlpha(0.5);

$pdf是类对象TCPDF参考 TCPDF 文档