Set the background color in TCPDF

蹲街弑〆低调 提交于 2019-12-11 08:04:38

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!