php中的pdf模板有解决方案吗? [英] Is there a solution for pdf template in PHP?
本文介绍了php中的pdf模板有解决方案吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要用PHP生成pdf格式的引号,并带有从数据库中检索到的模板和动态值.
I need to generate quotes in pdf format by PHP, with a template and dynamic values retrieved from database.
可行吗?
推荐答案
更新:我最近看到有人对此表示支持,并希望添加 wkhtmltopdf 可能是一个更好的选择.
UPDATE: i see people upvoting this recently and wanted to add that wkhtmltopdf might be a better option for most applications.
是, fpdf + 基本上,您首先创建pdf模板,然后将其加载到新的FPDI对象中,并使用FPDF函数在模板上绘制模板",就像photoshop图层一样.
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
这篇关于php中的pdf模板有解决方案吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文