VIKRANT SHARMA
VIKRANT SHARMA

Reputation: 107

FPDF page break in fpdf

I am using PHP and FPDF to generate a PDF with a list of items. My problem is, item does not goes to a second or third page.

I want to print next block of data in 2nd page of pdf. Someone please help me. I have used setautopage break() but not working.
PLEASE HELP!

       <?php

        require('fpdf.php');

        class PDF extends FPDF {

            function Header() { 

                $this->SetFont('Arial','B',10);    
                $this->Rect(50,30,100,30,'F');
                $this->Text(80,45,"3D");
                $this->SetXY(20,20);
                $this->Cell(30,10,'A',1,0,'L');             
                $this->SetXY(80,20);
                $this->Cell(30,10,'B',1,0,'L');                                         
                $this->SetXY(80,60);
                $this->Cell(30,10,'C',1,1,'L');             
                $this->SetXY(150,60);
                $this->Cell(30,10,'D',1,1,'L');             
            }   

            function Footer() {
                $this->SetY(-12);
                $this->Cell(169,20,'Page '.$this->PageNo().'/{nb}',0,0,'C');   
            }

            $pdf=new PDF();
            $pdf->AddPage(); 
            $pdf->SetFont('Arial','B',16);
            $pdf->AliasNbPages();
            $pdf->Output();

Upvotes: 1

Views: 4014

Answers (1)

Avinash Babu
Avinash Babu

Reputation: 6252

You would need to use GetY and Addpage for this purpose.

Use GetY to get the current position, subtract it from the height of your document. If that is less than 6x (you have 6 rows) your multicell height, then force a page break by using AddPage.

See a detailed answer here

Upvotes: 3

Related Questions