Niyas
Niyas

Reputation: 515

Page break for new page using fpdf

I want to create second page using fpdf.The code is given below.In the code from the specified area i want to start new page.Here the pdf class is extends from fpdf.

class PDF extends FPDF
 {

function header{
$this->Ln(20);
     $this->SetFont('Times','',10);
     $this->Cell(0,10,'Kondotty');
     $this->Ln(10);
     $this->SetFont('Times','',10);
     $this->Cell(80,0,'07/10/2014');


    $this->Cell(60,0,'Seal');
    $this->Cell(0,0,'Head of Institution');


//END FIRST PAGE

// STARTING SECOND PAGE




    $this->Ln(10);

    $this->Cell(27);
     $this->Cell(0,10,'Her conduct and character were found ...................................... during that period.');

     $this->Ln(20);
     $this->SetFont('Times','',10);
     $this->Cell(0,10,'Kondotty');
     $this->Ln(10);
     $this->SetFont('Times','',10);
     $this->Cell(80,0,'07/10/2014');
     }

    }  

Upvotes: 3

Views: 10705

Answers (1)

Matheno
Matheno

Reputation: 4142

For example:

I declare $i = 0; at the beginning of my PDF and for every line I add in my foreach I count $i like $i++. If you want a pagebreak after x lines for example you can just say:

if($i%30==0 && $i!=0) {
   $this->addPage();
}

And a function to add a new page:

private function addPage()
{
   $this->page = $this->pdf->newPage('A4');

I hope this will point you in the right direction.

Upvotes: 5

Related Questions