Ver Mensaje Individual
  #7 (permalink)  
Antiguo 21/06/2010, 20:33
Avatar de wiwi74
wiwi74
 
Fecha de Ingreso: marzo-2008
Mensajes: 515
Antigüedad: 16 años, 2 meses
Puntos: 10
Respuesta: Pie de pagina PDF

No te sirvio el que te di, bueno toma este... Es uno que ya tenia hecho, con un pie de pagina al final, solo que tube que simplificarlo.

Lee los comentarios, fijate que es lo que hace que algo se vea solo al final.

Código PHP:

require('fpdf.php');


class 
PDF extends FPDF
{

//footer de cada pagina (numero de parina)
function Footer()
{
    
    
//...sabemos que habra 2 paginas
    
if($this->PageNo() != "2"){
    
    
//Posición a 1,5 cm del final
    
$this->SetY(20);
    
//Arial itálica 8
    
$this->SetFont('Arial','I',8);
    
//Color del texto en gris
    
$this->SetTextColor(128);
        
//Número de página
    
$this->Cell(0,10,'Página '.$this->PageNo(),0,0,'R');
    
    }else{
    
    
////////////////////////////////////////////
    ////     pie de pagina                 /////

    //POSICION DEL FINAL
    
$this->SetY(-80);
    
//Arial itálica 8
    
$this->SetFont('Arial','I',18);
    
//Color del texto en rojo
    
$this->SetTextColor(255,000,000);
    
//Número de página
    
$this->Cell(0,10,'FINAL',0,0,'C');

    
////     pie de pagina                 /////
    ////////////////////////////////////////////    

    
    
}
}



function 
ChapterTitle($num,$label)
{
    
//Arial 12
    
$this->SetFont('Arial','',24);
    
//Color de fondo
    
$this->SetFillColor(200,220,255);
    
//Título
    
$this->Cell(0,26,"$label",0,1,'C',true);
    
//Salto de línea
    
$this->Ln(10);
}



function 
ChapterAutor($num,$label)
{
    
//Arial 12
    
$this->SetFont('Arial','',14);
    
//Color de fondo
    
$this->SetFillColor(245,245,245);
    
//Autor
    
$this->Cell(0,6,"$label",0,1,'C',true);
    
//Salto de línea
    
$this->Ln(10);
}



function 
ChapterBody($file)
{
    
//Leemos el fichero
    
$f=fopen($file,'r');
    
$txt=fread($f,filesize($file));
    
fclose($f);
    
//Letra del contenido principal
    
$this->SetFont('helvetica','',16);
     
     
//Imprimimos el texto justificado
    //el segundo paramero es el salto de linea
    
$this->MultiCell(0,8,$txt);
    
    
//Salto de línea
    
$this->Ln();
    
//Cita en itálica
    
$this->SetFont('','I');
    
//$this->Cell(0,5,'(fin del extracto)');
    
}

function 
PrintChapter($num,$title,$file)
{
    
$this->AddPage();
    
//titulo
    //$this->ChapterTitle($num,$label);
    //autor
    //$this->ChapterAutor($num,"Autor: Nombre del autor.");
    
$this->ChapterBody($file);
}
}

$pdf=new PDF();
$pdf->PrintChapter(1,'','paises.txt');
$pdf->Output('',''); 

ese codigo esta hacho para leer una archivo llamado paises.txt con este contenido:

Austria;Vienna;83859;8075
Belgium;Brussels;30518;10192
Denmark;Copenhagen;43094;5295
Finland;Helsinki;304529;5147
France;Paris;543965;58728
Germany;Berlin;357022;82057
Greece;Athens;131625;10511
Ireland;Dublin;70723;3694
Italy;Roma;301316;57563
Luxembourg;Luxembourg;2586;424
Netherlands;Amsterdam;41526;15654
Portugal;Lisbon;91906;9957
Spain;Madrid;504790;39348
Sweden;Stockholm;410934;8839
United Kingdom;London;243820;58862
Austria;Vienna;83859;8075
Belgium;Brussels;30518;10192
Denmark;Copenhagen;43094;5295
Finland;Helsinki;304529;5147
France;Paris;543965;58728
Germany;Berlin;357022;82057
Greece;Athens;131625;10511
Ireland;Dublin;70723;3694
Italy;Roma;301316;57563
Luxembourg;Luxembourg;2586;424
Netherlands;Amsterdam;41526;15654
Portugal;Lisbon;91906;9957
Spain;Madrid;504790;39348
Sweden;Stockholm;410934;8839
United Kingdom;London;243820;58862
Austria;Vienna;83859;8075
Belgium;Brussels;30518;10192
Denmark;Copenhagen;43094;5295
Finland;Helsinki;304529;5147
France;Paris;543965;58728
Germany;Berlin;357022;82057
Greece;Athens;131625;10511
Ireland;Dublin;70723;3694
Italy;Roma;301316;57563
Luxembourg;Luxembourg;2586;424
Netherlands;Amsterdam;41526;15654
Portugal;Lisbon;91906;9957
Spain;Madrid;504790;39348
Sweden;Stockholm;410934;8839
United Kingdom;London;243820;58862