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
#2

You did not tell us which PDF library your using.

See if your watermark allows Transparency.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

I am using Fpdi library.
Learning Codeigniter 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB