cloudseeker
cloudseeker

Reputation: 275

Set TCPDF background colour for the rest of page

I have been trying to colour the bottom part (remittance/pay to details) of a TCPDF invoice but can only colour individual cells at a time. The first column is made up of cells and the second and third columns are made up of multicells. I just can't work out how to just do a flat colour within the margins (and possibly the ability to frame with a border).

Can someone please advise if the first line will infact keep the remittance at the bottom, or if it will move down with the page (and end up on the next page) if more line items are added to the invoice.

It all starts off with...

$pdf->SetXY(142, 225);


# Payment Details
$pdf->Ln(2);
$pdf->SetFillColor(100);

Upvotes: 1

Views: 2774

Answers (1)

cloudseeker
cloudseeker

Reputation: 275

Okay... Not sure if this is the best way, but it worked for me so will just tick it off my list and move on, lol.

It is essentially creating a box, and then putting the text over the top...

$pdf->SetXY(142, 247);
$pdf->SetFillColor( 235, 245, 255 );
$pdf->Rect( 0, 237, $pdf->getPageWidth(),'60', 'F' );

and then the original bit...

# Payment Details
$pdf->Ln(2);

but this bit isn't needed because you don't need to colour the cells

$pdf->SetFillColor(100);

The box needs to be before the content otherwise it will sit on top. :-) Hopefully this helps someone else out! :-)

Upvotes: 2

Related Questions