Welcome Guest, Not a member yet? Register   Sign In
FPDI watermark on pdf
#1

I have been trying to add a watermark on an existing pdf, and so far I have done it successfully but the Issue that I am facing is that a watermark is being added over the content, if anyone knows how to set it behind content, I would be really grateful for any help. 
Screenshot of  generated pdf
here's my code - 
PHP Code:
function fpdi()
    {
        $file 'dynamics/client-documents/P8/C10/1670573576_e86485fff7bd3890261c.pdf';

        $pdf = new Fpdi();
        $watermarkText setting(UPLOAD_SETTING.'watermarkText');

        $pages_count $pdf->setSourceFile($file);
        for ($i 1$i <= $pages_count$i ++) {
            $pdf->AddPage();
            $tplIdx $pdf->importPage($i);
            $pdf->useTemplate($tplIdx00);
            $pdf->SetFont('Arial','B',50);
            $pdf->SetTextColor(192192192);
            $this->addWatermark(105220$watermarkText45$pdf);
            $pdf->SetXY(2525);
        }
        $pdf->Output('D''my-document.pdf');
    }



    function addWatermark($x$y$watermarkText$angle$pdf)
    {
        $angle $angle M_PI 180;
        $c cos($angle);
        $s sin($angle);
        $cx $x 1;
        $cy = (300 $y) * 1;
        $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm'$c$s, - $s$c$cx$cy, - $cx, - $cy));
        $pdf->Text($x$y$watermarkText);
        $pdf->_out('Q');
    
Learning Codeigniter 
Reply


Messages In This Thread
FPDI watermark on pdf - by SubrataJ - 12-09-2022, 03:46 AM
RE: FPDI watermark on pdf - by InsiteFX - 12-10-2022, 12:39 AM
RE: FPDI watermark on pdf - by SubrataJ - 12-10-2022, 06:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB