【发布时间】:2015-10-08 08:07:27
【问题描述】:
感谢 FPDF,我创建了一个 PDF 生成器,它使用 mysql 数据库中的数据并且运行良好。页数是可变的。
然后我想在每个 PDF 中添加一些从其他 PDF 文件导入的页面。添加的页数和导入文件的地址也是可变的。
效果很好,只是我的页脚不再出现。我想在每一页上保留这个页脚,由生成器创建的页脚和导入的页脚。谁能告诉我问题出在哪里?..
这是我的代码:
require_once('gpdf/fpdf.php');
require_once('gpdf/fpdi.php');
class PDF extends FPDI
{
function Header()
{
}
function Footer()
{
// Positionnement à 1,5 cm du bas
$this->SetY(-15);
// Police Arial italique 8
$this->SetFont('Arial','I',8);
// Numéro de page
$this->Cell(0,10,'Devis from MyCompany - Page '.$this->PageNo().'/{nb}'.' Paraphes :',0,0,'C');
}
}
// Instanciation de la classe dérivée
$pdf = new FPDI();
$pdf->AliasNbPages();
$pdf->AddPage();
// Here is page 1, you don't need the details
$pdf->AddPage();
// Here is page 2, some other pages can come too
// Then begins the importation
// get the page count
$pageCount = $pdf->setSourceFile('cgua/cgu_'.$customer['num'].'.pdf');
// iterate through all pages
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
// 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);
}
$pdf->Output('devis.pdf','I');
我在 FPDI 的手册中没有找到关于如何保留 Footer 的解释...我确信解决问题很容易,只是我没有找到方法!
谢谢!
【问题讨论】:
-
你试过在
$pdf->AddPage()之后手动调用$pdf->Footer()吗?