Forums

PDF Background Colour

K2Joom 27 Jun, 2014
My form, when submitted, provides a PDF download of the form data, excellent!!

The one thing I have been trying to do, thanks to a user request😟 is to change the whole background colour of the pdf.
I have looked through the tcpdf docs on their site, but have not seen anything that shows an example of such a thing. Setting a fill colour for cells, yes but not the whole page.

I have tried adding a body class such as
body {background:#FFEDD4;}
and
body {background-color:#FFEDD4;}
but it is not being changed.

Not sure if this is even possible, or maybe something has to be added to form_actions/tcpdf/cfaction_tcpdf.php

If anyone has done the same, it would be great to hear from you
K2Joom 27 Jun, 2014
Hi Bob,

Sort of helps🙂

I started off by using their working code
// Extra header voor background color
class MYPDF extends TCPDF {
    //Page header
    public function Header() {
        // Background color      
        $this->Rect(0,0,210,297,'F','',$fill_color = array(255, 170, 96));
    }
}

But that failed to load the pdf.

I wondered if the class MYDF might have been an issue, so changed the code to:

// Extra header voor background color
class TCPDF {
    //Page header
    public function Header() {
        // Background color      
        $this->Rect(0,0,210,297,'F','',$fill_color = array(255, 237, 212));
    }
}


Both were added directly before the $pdf = new

Even tried adding:
$this->Rect(0,0,210,297,'F','',$fill_color = array(255, 237, 212));
and
$pdf->Rect(0,0,210,297,'F','',$fill_color = array(255, 237, 212)); 


More digging required.
This topic is locked and no more replies can be posted.