首页 > 解决方案 > 带有 fpdf 的第二张 pdf 表没有正确输出

问题描述

一个帮助,第一张纸正确出现,但第二张纸没有,我得到了几张我希望有人能帮我解决这个问题因为我是新手,只是那个错误,从第二页开始,一切都被扭曲了我附上我的代码,看看他们是否可以帮助我

    <?php

class Pdfhojavida extends FPDF{

function Head($y){
    //Margen
    $this->SetLineWidth(0.1);
    $this->SetFillColor(255);
    $x=5; $y+=5; $w=50; $h=60;
    $this->Image('../public/img/logo.jpeg',$x,$y,$w,$h,'jpeg','');
    // $this->Cell(0,20,utf8_decode('REGISTRO DIARIO DE PACIENTES EN CONSULTA EXTERNA'),0,0,'C');
    

    // $this->SetTextColor(0,0,0);
    $y+=5;
    $this->setY($y);
    $this->setX(158);
    $this->SetFont('Arial','B',10);
    $this->Cell(50,10,'FECHA IMPRESION: '.date('Y-m-d'),0,0,'L');
    // $this->Cell(50,10,'SIS-Demo-ECE',0,0,'L');
    $y+=5;
    $this->setY($y);
    $this->setX(5);
    $this->SetFont('Arial','B',12);
    $this->SetTextColor(0,0,0);
    $this->Cell(0,20,utf8_decode('HOJA DE VIDA DE LA MASCOTA'),0,0,'C');
    
}
function Top($y,$dataconsulta){
    $x = 6;
    $this->setY($y);
    $this->setX($x);
    $this->SetFont('Arial','B',8);
    $this->Cell(30,5,utf8_decode('Fecha nacimiento'),1,0,'C');
    $this->ln(5);
    $this->setX($x);
    $this->SetFont('Arial','',7);
    $this->Cell(30,5,$dataconsulta[0]->fechaNac,1,0,'L');

    $x = $this->GetY() + $x;
    $this->setY($y);
    $this->setX($x-9);
    $this->SetFont('Arial','B',8);
    $this->Cell(40,5,utf8_decode('Mascota'),1,0,'C');
    $this->ln(5);
    $this->setX($x-9);
    $this->SetFont('Arial','',7);
    $this->Cell(40,5,utf8_decode($dataconsulta[0]->mascota),1,0,'L');
    
    $x = $this->GetY() + $x;
    $this->setY($y);
    $this->setX($x-8);
    $this->SetFont('Arial','B',8);
    $this->Cell(40,5,utf8_decode('Especie'),1,0,'C');
    $this->ln(5);
    $this->setX($x-8);
    $this->SetFont('Arial','',7);
    $this->Cell(40,5,utf8_decode($dataconsulta[0]->especie),1,0,'L');
    
    $x = $this->GetY() + $x;
    $this->setY($y);
    $this->setX($x-7);
    $this->SetFont('Arial','B',8);
    $this->Cell(30,5,utf8_decode('Raza'),1,0,'C');
    $this->ln(5);
    $this->setX($x-7);
    $this->SetFont('Arial','',7);
    $this->Cell(30,5,utf8_decode($dataconsulta[0]->raza),1,0,'L');
    
    $x = $this->GetY() + $x;
    $this->setY($y);
    $this->setX($x-16);
    $this->SetFont('Arial','B',8);
    $this->Cell(60,5,utf8_decode('Cliente'),1,0,'C');
    $this->ln(5);
    $this->setX($x-16);
    $this->SetFont('Arial','',7);
    $this->Cell(60,5,utf8_decode($dataconsulta[0]->nombre_cliente),1,0,'L');
    
}
function Body($y,$dataservicio,$arrayServicios){

    $x = 6;
    $this->setY($y);
    $this->setX($x);
    $this->SetFont('Arial','B',12);
    $this->Cell(30,6,utf8_decode('Registro de Consultas'),0,0,'L');
    $this->ln();
  
    $y += 8;       

    foreach ($dataservicio['consultas'] as $ll => $consulta) {
                
        $key = 0;
        $this->setY($y);
        $this->setX($x);
        $this->SetFont('Arial','B',10);
        $this->Cell(177,6,utf8_decode('Fecha Consulta: '). $consulta[$key]->fecha,0,0,'C');
        $this->SetFont('Arial','B',10);
        $this->Cell(200,6,utf8_decode('Peso: '). $consulta[$key]->pesoMascota.' KG',0,0,'L');

        $y += 8;
        
        $this->setY($y);
        $this->setX($x);  
        $this->SetFont('Arial','B',8);
        $this->Cell(84,6,utf8_decode('Servicio'),1,0,'L');
        $this->SetFont('Arial','B',8);
        $this->Cell(90,6,utf8_decode('Observación'),1,0,'L');
        $this->SetFont('Arial','B',8);
        $this->Cell(30,6,utf8_decode('Precio Sugerido'),1,0,'L');           
        
        $this->ln();
        $total = 0;
        $y += 6;
        foreach ($arrayServicios[$ll]as $kk => $servicio) {
                            
            if($consulta[$key]->id == $servicio->id){
                
                    $this->setY($y);
                    $this->setX($x);        
                    $this->SetFont('Arial','',8);
                    $this->Cell(84,6,utf8_decode($servicio->servicio),1,0,'L');      
                    $this->Cell(90,6,utf8_decode($servicio->observacion),1,0,'L');  
                    $this->Cell(30,6,utf8_decode($servicio->precio).' Soles',1,0,'L');
                    $this->ln();                
                    $y += 6;
                
            }
            $total +=  $servicio->precio;
        }
        $this->setY($y);
        $this->setX($x+149);   
        $this->SetFont('Arial','B',10);
        $this->Cell(25,6,utf8_decode('Total'),1,0,'R');      
        $this->Cell(30,6,$total.' Soles',1,0,'L');    

        $y += 5;
        $this->setY($y);
        $this->setX($x);
       

    }
        
}  

}

示例 1 示例 2

标签: phpfpdf

解决方案


推荐阅读