我有一个Wordpress网站。我想允许用户下载(和/或打印)一份政府发布的表格(pdf格式),该表格已经填满了从网站数据库中提供的数据(如姓名、地址、支付金额等)。
在编码php之前,有没有Wordpress插件可以做到这一点(我是Wordpress的新手)?顺便说一下,我已经有了重力表单。
发布于 2014-11-04 23:53:33
我不知道Wordpress,但在PHP中使用FPDF和FPDI可以非常简单地做到这一点。
<?php
require_once('fpdf.php');
require_once('fpdi.php');
$pdf = new FPDI();
// get the page count
$pageCount = $pdf->setSourceFile('base.pdf');
// iterate through all pages
$pageNo = 1;
// import a page
$templateId = $pdf->importPage($pageNo);
// get the size of the imported page
$size = $pdf->getTemplateSize($templateId);
// create a page (landscape or portrait depending on the imported page size)
if ($size['w'] > $size['h']) {
$pdf->AddPage('L', array($size['w'], $size['h']));
} else {
$pdf->AddPage('P', array($size['w'], $size['h']));
}
// use the imported page
$pdf->useTemplate($templateId);
// set the font typeface and size
$pdf->SetFont('Helvetica');
$pdf->setFontSize(20);
// set position where to write
$pdf->SetXY(10, 10);
$pdf->Write(8, 'Hello World!');
// don't save a local copy, but instead output stream to the browser
$pdf->Output("output.pdf", "I");
发布于 2014-11-05 00:07:38
看一下:https://wordpress.org/plugins/gravity-forms-pdf-extended/
在用户提交重力表单时保存PDF文件,以便可以将其附加到notification
https://stackoverflow.com/questions/26739118
复制相似问题