I have a docx document file set up with formating and layout, which I saved as a PDF file. I want to use this pdf file as a template for creating new pdf files pre-filled with user data.
I have seen FPDF, FPDI, tcPDF, domPDF, Zend PDF, http://koivi.com/fill-pdf-form-fields/ (Justin Koivisto), a few convertion tools like HTML2PDF and a few command line tools mentioned here on stackoverflow. With the exception of FPDI, none of them offer an example using a PDF template to either search-and-replace custom tags with actual data (usually from a database) or add data without specifying a bunch of values like x, y, postion, font, font-formating etc.
Creating a PDF from scratch seems like too much work. I have not yet considered using a HTML2PDF converter as the results appear to vary greatly, and then there is the issue with styling. Some tools allow CSS, but often with limits like no float support.
Are there no easy way of using a template like there is for Excel with PHPExcel ?
My need is:
php require('./fpdf. php'); $pdf=new FPDF(); $pdf->AddPage(); $pdf->SetFont('Arial','B',16); $pdf->Cell(40,10,'Hello World! '); $pdf->Output(); ?> Upon execution, the PHP script will generate a PDF file in your browser.
To generate a pdf file, first, we need to include the library file fpdf. php. Then we need to create an FPDF object using the default constructor FPDF().
I really recommend MPDF :
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With