2
我已经使用FPDF创建了PDF生成器,它使用来自mysql数据库的数据并且工作得很好。页数是可变的。在FPDI中添加页脚
然后我想添加到这个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手册解释......我敢肯定,这容易解决问题,我只是没有找到方法!
谢谢!
您是否试图在'$ pdf-> AddPage()'之后手动调用'$ pdf-> Footer()'? –