How to use PDFTK background in php?

240 views Asked by At

PHPTK has a option that allows library devs to set a background for the pdf that is generated and here is the link - https://github.com/mikehaertl/php-pdftk#add-background-pdf

But in short it tells to add -

$pdf->background('/path/back.pdf')

But when I use this in my code it doesn't work I mean the back.pdf is not a background inside my generated pdf.

public function generate($pdfdata)
        {
            $pdfname = 'pdf_'.rand(2000, 1200000).'.pdf';
            $pdf = new Pdf("./rawpdf/test.pdf");
            
            $pdf->fillForm($pdfdata)
            ->flatten()
            ->needAppearances()
            ->saveAs("./generated/".$pdfname);            
            return $pdfname;
            
        }

In my thought process I think If i use the background then it should be behind the text or can be said over the generated pdf but those things don't happen by the way if i am using this not correctly please correct me I new to this library.

0

There are 0 answers