Search code examples
phpfpdf

FPDF- SetFillColor


Could anyone explain to me how this function in FPDF works? I can't seem to get any color from it, using this code:

function Header()
    {
        // Logo
        $this->Image($_SERVER['DOCUMENT_ROOT'].'/assets/documents/barcodes/'.$_SESSION["loggedin"].'.png',10,6,30);
        // Arial bold 15
        $this->SetFont('Arial','B',15);
        // Move to the right
        $this->Cell(80);
        // Title
        $this->Cell(75,25,'Technische beurs Sax',1,0,'C');
        // Line break
        $this->SetFillColor(0, 255, 0);
        $this->Ln(40);
    }

This function gets called in a class PDF that extends the normal FPDF class, according to this example: http://www.fpdf.org/en/tutorial/tuto2.htm.

For an example, this is what the "end result" should look like: http://technischforum.sax-professional.be/assets/documents/BevestigingMail.pdf


Solution

  • SetFillColor doesn't work on the entire page, to work around this add a rect and fill it

    this is a black A4

    $pdf->SetFillColor(0,0,0);
    $pdf->Rect(0, 0, 210, 297, 'F');
    

    then SetXY back to the required position