问题
I have set the background color for the first page manually like this:
$pdf->AddPage();
$pdf->SetFillColor(52, 21, 0, 76);
$pdf->Rect(0, 0, $pdf->getPageWidth(), $pdf->getPageHeight(), 'DF', "");
I'm trying to set the background color inside a for-each loop in case the elements jump on to the next page using this.
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);
}
But still I fail to do this.
来源:https://stackoverflow.com/questions/46291778/set-the-background-color-in-tcpdf