FPDF Error: Template Does Not Exist! FPDF

So, I am trying to change the pdf template using php.

I looked around and found that most people use FPDI, and I tried.

So what I did was

include('pdf/fpdf.php'); include('pdf/fpdi.php'); // initiate FPDI $pdf = new FPDI(); // add a page $pdf->AddPage(); // set the sourcefile $pagecount = $pdf->setSourceFile('pdf/menu_blanka.pdf'); // import page 1 $template = $pdf->importPage($pagecount); // use the imported page as the template $pdf->useTemplate($template, 0,0,0); 

And I constantly get this error "FPDF error: the template does not exist!".

Can you guys help me?

+5
source share
1 answer

This is how I achieved this in my project. It works great.

 require_once 'pdf/fpdf.php'; require_once 'pdf/fpdi.php'; $pdf = new FPDI(); $pdf->setSourceFile('/path/to/source.pdf'); $pdf->AddPage(); $tplidx = $pdf->ImportPage(1); $pdf->useTemplate($tplidx, 0, 0, 0); $output = $pdf->Output('output.pdf', "S"); 
0
source

Source: https://habr.com/ru/post/1232246/


All Articles