Question

I believe there is no native method in TCPDF to create drop shadows. Any ideas how I could create such an effect with any of its other methods? I was first thinking of creating a small gradient next to each edge (for rectangles) but found no way to create gradients with different alpha channels.

Was it helpful?

Solution

Something like this:

class MYPDF extends TCPDF {
    public function addShadow($x,$y,$h,$w){

        for($i=5;$i>=1;$i-=0.5){
            $this->SetAlpha(0.1-($i*0.02));
            $this->SetFillColor(0, 0, 0);
            $this->SetDrawColor(0, 0, 0);
            $this->Rect($x+$i, $y+$i, $h, $w, 'DF');
        }

        $this->SetAlpha(1);
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top