2

I managed quite easily to add an image to a pdf file with fpdi class with the script below in Laravel environment.

        $pdf = new \setasign\Fpdi\Fpdi();

        // set PDF file & get page count
        $pageCount = $pdf->setSourceFile("MultiplePage.pdf");

        // loop pages
        for ($p = 1; $p <= $pageCount; $p++) {

            // import page p
            $tppl = $pdf->importPage($p);

            // add page p
            $pdf->AddPage();

            // use the imported page and adjust the page size
            $pdf->useTemplate($tppl, ['adjustPageSize' => true]);

            // insert image at position x,y,w,h (in mm)
            $pdf->Image("Logo.png",170,5,36,22);

        }

        // save new pdf
        $pdf->Output("NewPDF.pdf", "F");

It works 100% but I struggled to find detailed info how to use each of the command and which parameter units are used (i.e. for $pdf->Image).

Can someone point to that doc please?

Paul Godard
  • 1,055
  • 1
  • 14
  • 30

0 Answers0