Php 在TCPDF中设置背景色
我已经手动设置了第一页的背景色,如下所示:Php 在TCPDF中设置背景色,php,html,css,tcpdf,Php,Html,Css,Tcpdf,我已经手动设置了第一页的背景色,如下所示: $pdf->AddPage(); $pdf->SetFillColor(52, 21, 0, 76); $pdf->Rect(0, 0, $pdf->getPageWidth(), $pdf->getPageHeight(), 'DF', ""); 我试图在for each循环中设置背景色,以防元素使用此选项跳转到下一页 if (!empty($extra_curricular_data)) { foreach
$pdf->AddPage();
$pdf->SetFillColor(52, 21, 0, 76);
$pdf->Rect(0, 0, $pdf->getPageWidth(), $pdf->getPageHeight(), 'DF', "");
我试图在for each循环中设置背景色,以防元素使用此选项跳转到下一页
if (!empty($extra_curricular_data)) {
foreach ($extra_curricular_data as $data) {
$extra_curricular_details .= <<<EOD
<p style="font-family: courier; color: #F5F5F5;"><strong> {$data['title']}</strong></p>
<p style="color: #F5F5F5;">{$data['description']}</p>
EOD;
if ((int)$pdf->getAliasNumPage() > 1) {
$this->SetFillColor(52, 21, 0, 76);
$this->Rect(0, 0, $this->getPageWidth(), $this->getPageHeight(), 'DF', "");
}
}
$pdf->writeHTMLCell(0, 0, '', '', $extra_curricular_details, 1, 1, 0, true, 'L', true);
}
if(!empty($extractural\u data)){
foreach($data形式的课外数据){
$Extral_-currential_details.=SetFillColor(52,21,0,76);
$this->Rect(0,0,$this->getPageWidth(),$this->getPageHeight(),'DF',“”);
}
}
$pdf->WriteHTML单元格(0,0,,'','',$Extral\u-culturer\u-details,1,1,0,true,'L',true);
}
但我还是没能做到。可能是重复的。你读过我写的关于函数rect如何工作的文章吗?我将其标记为重复,并在原始答案上编辑我的答案