I need to generate quotes in pdf format by PHP, with a template and dynamic values retrieved from database.
is it viable ?
UPDATE: i see people upvoting this recently and wanted to add that wkhtmltopdf might be a better option for most applications.
yes, fpdf + fpdi worked for me
basically, you create your pdf template first, then load it into the new FPDI object and use FPDF functions to draw "over" the template - much like photoshop layers work.
$pdf = new FPDI();
$pdf->setSourceFile('template.pdf');
$tpl = $pdf->importPage(1);
$pdf->addPage();
$pdf->useTemplate($tpl); <- template is imported
$pdf->setXY(10, 20);
$pdf->write(100, "Hi there"); <- write or draw something on the template
$pdf->output('newpdf.pdf', 'D'); <- ready, save or output your pdf
Try the DOMPDF. It's very good & easy to use, and has got some very useful APIs. I have used it twice, and it really amazes me as to what not you can do.
Really, you can set multiple pages in the on-the-fly created PDF, with resized images acting as catalog products.
It has a very good Documentation, with examples shown. If you have any problems integrating it, feel free to post your question here, and the users will be proactive in answering your questions.
DOMPDF is an awesome cool stuff. I think that it has also won some awards, for its sheer coding standard. Check out yourself, for more!!!
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