在使用php打印出每个pdf页面后,如何增加pdf中的收据编号?

时间:2015-03-16 04:45:50

标签: php pdf fpdf

我需要在每个pdf的打印输出后递增显示收据编号,我使用fpdf创建收据,我想计算第1页的收据编号,第2页等的收据编号。

我可以使用会话吗?

感谢任何帮助。

这是我的pdf代码:

<?php
    if(!empty($_POST['register']))
    {
        $calender=$_POST['datum1'];
        $time=$_POST['timepicker_6'];
        $respected=$_POST['first_name'];
        $month=$_POST['second_name'];
        $year=$_POST['third_name'];
        $fees=$_POST['fourth_name'];
        $amount=$_POST['fifth_name'];
    require("fpdf/fpdf.php");

    $pdf=new FPDF();
    $pdf->Addpage();
    // Logo
    $pdf->Image('33990.jpg',10,2,30);
    $pdf->SetFont("Arial","B",20);
    $pdf->cell(0,10,"Madirasheri Mahal Jamath ",0,1,'C');
    $pdf->SetFont("Arial","B",18);
    $pdf->cell(0,10,"P.O Thrikanapuram-679573,register number:529/98 ",0,1,'C');

    $pdf->SetFont("Arial","B",18);
    $pdf->Cell(0,10,"Receipt number:",0,0,'C');

    $pdf->SetFont("Arial","B",18);
    $pdf->cell(0,10,"Date:{$calender} ",0,1,'R');  


    $pdf->cell(0,10,"Time:{$time}",0,1,'R');


    $pdf->cell(0,30,"We have received sum of Rs  {$fees},for the month of ",0,1);

    $pdf->cell(0,-15,"{$month},{$year} From Mr/Mrs {$respected}.",0,1);

    $pdf->cell(0,60,"Amount :{$amount} ",0,1);
    $pdf->cell(0,20,"Secretory: ........... ",0,1,'R');

    $pdf->output();
    }
?>

我使用的是fpdf:http://www.fpdf.org

1 个答案:

答案 0 :(得分:0)

FPDF附带一个名为PageNo的内置函数,可以完成你需要的功能。

$pdf->Cell(0,10,"Receipt number: ".$pdf->PageNo(),0,0,'C');