0

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.

somp60
  • 1
  • 1
  • 1
    Guessing `'/path/back.pdf'` is just a placeholder name for the documentation, replace it with a real path to a .pdf in your project, also you're not calling `background` in `generate` anyway? – Kim Hallberg Apr 16 '21 at 12:47
  • @KimHallberg I am just taking that as example but if i want to apply this inside my project then how can I please in detail if I take my initial directory where I have saved the pdf and want to take the 2nd fille from there and set the background for the that is being generated please reply with adding that background code with my code please sir. – somp60 Apr 16 '21 at 13:06

0 Answers0