Foros del Web » Programando para Internet » PHP »

php y fpdf.php

Estas en el tema de php y fpdf.php en el foro de PHP en Foros del Web. hola que tal a todos saben tengo un problema con la ibreria fpdf.php. Al realizar el reporte pdf el tamaño de la hoja siempre me ...
  #1 (permalink)  
Antiguo 06/12/2006, 13:51
Avatar de ikaroraul  
Fecha de Ingreso: octubre-2006
Ubicación: La Paz
Mensajes: 391
Antigüedad: 17 años, 6 meses
Puntos: 16
php y fpdf.php

hola que tal a todos
saben tengo un problema con la ibreria fpdf.php.

Al realizar el reporte pdf el tamaño de la hoja siempre me sale A4 y lo que quiero es cambiar ese tamaño.

como lo hariaaa

Código PHP:
<?php
require('fpdf.php');

class 
PDF extends FPDF
{
//Cargar los datos
function LoadData($file)
{
    
//Leer las líneas del fichero
    
$lines=file($file);
    
$data=array();
    foreach(
$lines as $line)
    
$data[]=explode(';',chop($line));
    return 
$data;
}

function 
LoadDataCan($file)
{
    
$linescan=file($file);
    
$datacan=array();
    foreach(
$linescan as $linecan)
    
$datacan[]=explode(';',chop($linecan));
    return 
$datacan;
}

//Tabla coloreada
function Header()
{
    
$usuario=$_COOKIE['nombrev'];
    
$this->SetFont('Arial','B',12);
    
$this->Cell(0,10,'"mi empresa."',0,0,'L');
    
$this->setXY(20,14);
    
$this->SetFont('Arial','',6);
    
$this->Cell(15,10,'mi pais',0,0,'L');
    
$this->Ln();$this->Cell(80);    
    
$this->SetFont('Arial','',12);
    
$this->Cell(80,0,'Bloques Espuma de Produccion',0,0,'C'); 
 
    
$this->SetFont('Arial','',8);
    
$this->setXY(250,20);
    
$this->Cell(0,10,'Hoja: '.$this->PageNo(),0,0,'R');
    
$this->Line (10,27,290,27);
    
    
$this->setXY(250,20);
    
$this->SetFont('Arial','B',10);
    
$this->Cell(20,0,'Nº: 157846884',0,0,'L');
    
$a=$_COOKIE['nombrev'];
    
$this->setXY(10,30);
    
$this->SetFont('Arial','I',7);
    
$this->Cell(20,0,'Usuario:'.$a.'.',0,0,'L');
    
    
$this->setXY(80,30);
    
$this->SetFont('Arial','I',7);
    
$this->Cell(20,0,'Departamento: Produccion de Bloques de Espuma',0,0,'L');
    
    
$this->setXY(10,35);
    
$this->Cell(20,1,'Fecha: '.dated.'/'.m.'/'.y),0,0,'L'); 
    
    
$this->setXY(80,35);
    
$this->Cell(20,1,'Hora : '.date('g:i:s a'),0,0,'L'); 
    
$this->SetFont('Arial','I',8);
    
    
$this->Line (10,40,290,40);    
    
$this->Ln(10);
}
 
function 
FancyTable($header,$tipo,$data,$datacan)
{
    
//Colores, ancho de línea y fuente en negrita
    
$this->SetFillColor(230,230,230);
    
$this->SetTextColor(0);
    
$this->SetDrawColor(10,0,0);
    
$this->SetLineWidth(0.1);
    
$this->SetFont('','B');
    
    
//Cabecera
    
$w=array(23,23); // Ancho y Numero de las columnas
    
$ww=array(5,13,17); // Ancho y Numero de las columnas
    
$www=array(5,13,17,23); // Ancho y Numero de las columnas
    
    
for($i=0;$i<count($header);$i++)
    
$this->Cell($ww[$i],3,$header[$i],'LRT',0,'C',1); //Ancho,Alto,Titulo,borde,estilo,Align
    
    
foreach($data as $row)
    
$this->Cell($w[0],3,$row['0'],'LRT',0,'C',1);
    
$this->Ln();
    
    for(
$i=0;$i<count($header);$i++)
    
$this->Cell($ww[$i],3,'','LRB',0,'C',1);
    
    foreach(
$data as $row)
    
$this->Cell($w[1],3,$row['1'],'LRB',0,'C',1);
    
$this->Ln();
    
$fill=0;
    foreach(
$datacan as $row)
    {
    
$this->Cell($www[0],3,$row['0'],'LRTB',0,'C',$fill);
    
$this->Cell($www[1],3,$row['1'],'LRTB',0,'C',$fill);
    
$this->Cell($www[2],3,$row['2'],'LRTB',0,'C',$fill);
    
$this->Cell($www[3],3,$row['3'],'LRTB',0,'C',$fill);
    
$this->Cell($www[3],3,$row['4'],'LRTB',0,'C',$fill);
    
$this->Cell($www[3],3,$row['5'],'LRTB',0,'C',$fill);
    
$this->Cell($www[3],3,$row['6'],'LRTB',0,'C',$fill);
    
$this->Cell($www[3],3,$row['7'],'LRTB',0,'C',$fill);
    
$this->Cell($www[3],3,$row['8'],'LRTB',0,'C',$fill);    
    
$this->Cell($www[3],3,$row['9'],'LRTB',0,'C',$fill);
    
$this->Cell($www[3],3,$row['10'],'LRTB',0,'C',$fill);
    
$this->Cell($www[3],3,$row['11'],'LRTB',0,'C',$fill);
    
$this->Cell($www[3],3,$row['12'],'LRTB',0,'C',$fill);
    
$this->Ln();
        
$fill=!$fill;
    }

        
/*
    for($i=0;$i<count($tipo);$i++)
    $this->Cell($w[$i],4,$tipo[$i],'LRB',0,'C',1); //Ancho,Alto,Titulo,borde,estilo,Align
    $this->Ln();
    */
    //Restauración de colores y fuentes
    
$this->SetFillColor(224,235,255);
    
$this->SetTextColor(0);
    
$this->SetFont('');
    
//Datos
   
    
$this->Cell(array_sum($w),0,'','T');
}
}

$pdf=new PDF();
//Títulos de las columnas
$header=array('No','Densidad','Dimensiones');


//Carga de datos
$data=$pdf->LoadData('archivo.txt');
$datacan=$pdf->LoadDataCan('archivo2.txt');

$pdf->SetFont('Arial','',7);
$pdf->AddPage('L');
$pdf->FancyTable($header,$tipo,$data,$datacan);
$pdf->Output();
?>
gracias por la yuda
  #2 (permalink)  
Antiguo 06/12/2006, 14:54
 
Fecha de Ingreso: marzo-2006
Mensajes: 15
Antigüedad: 18 años, 1 mes
Puntos: 0
Re: php y fpdf.php

$pdf=new FPDF('P','mm','A4');

FPDF
FPDF([string orientation [, string unit [, mixed format]]])
Descripción
Esta es la clase constructor. Permite establecer el formato de página, la orientación y la unidad de medida usada en todos los métodos (excepto para tamaños de fuentes).
Parámetros
orientation
Orientación de página por defecto. Los posibles valores son (case insensitive):
P o Portrait (normal)
L o Landscape (apaisado)
Valor por defecto es P.
unit
Unidad de medida de usuario. Los posibles valores son:
pt: punto
mm: milimetro
cm: centimetro
in: pulgada
Un punto es igual a 1/72 de pulgada, es decir cerca de 0.35 mm (siendo una pulgada 2.54 cm). Esta es una unidad muy común en tipografía; los tamaños de fuentes son expresados en esa unidad.

Valor por defecto es mm.
format
El formato usado por las páginas. Es puede ser uno de los siguientes valores (case insensitive):
A3
A4
A5
Letter
Legal
o un formato personalizado en la forma de un array de dos elementos conteniedo el ancho y el alto (expresado en la unidad dada por unit).

pagina principal fpdf.org
  #3 (permalink)  
Antiguo 06/12/2006, 15:20
Avatar de ikaroraul  
Fecha de Ingreso: octubre-2006
Ubicación: La Paz
Mensajes: 391
Antigüedad: 17 años, 6 meses
Puntos: 16
De acuerdo Re: php y fpdf.php

Muchas gracias mano..... enserio me ayudastes mucho.... gracias gracias
Si funciona.. ahora si puedo cambiar el tipo de papel....
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:14.