Create new PDF from template with PHP Create new PDF from template with PHP php php

Create new PDF from template with PHP


I really recommend MPDF :

  1. it is based on FPDF and HTML2FPDF, so you can use some of their functions or add others
  2. it has tons of cool features (create any kind of barcodes, locale support, watermarks, and many more)
  3. it has an extremely well made documentation
  4. it has a community forum
  5. it has examples!
  6. it has an easy learning curve

The only bad thing is that it is a little heavy-weight, but you can remove things that you dont need.


use TCPDF you can create the PDF template using HTML tags principles it is fast to create, easy to use, easy to integrate I used it for generating detailed invoices of a law office(multiple pages with different format), the production envelope of a jewellery workshop (included photo), stock notes and invoices.

TCPD examples


try FPDI it support editing an existing template and making changes in that template file

usage is pretty stratight forward :

<?phprequire_once('fpdf.php');require_once('fpdi.php');$pdf = new FPDI();$pagecount = $pdf->setSourceFile('TestDoc.pdf');$tplidx = $pdf->importPage(1, '/MediaBox');$pdf->addPage();$pdf->useTemplate($tplidx, 10, 10, 90);$pdf->Output('newpdf.pdf', 'D');

Also refer to links below:Is there a solution for pdf template in PHP?

Writing/Drawing over a PDF template document in PHP