简体   繁体   中英

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();

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM