Foros del Web » Programando para Internet » PHP »

Impresion en pdf

Estas en el tema de Impresion en pdf en el foro de PHP en Foros del Web. Buenos dias, cordial saludo. compañeros estoy realizando un aplicativo en php en la cual imprime formatos selecionando de varias tablas sus registros, ejemplo: en la ...
  #1 (permalink)  
Antiguo 17/09/2010, 10:19
 
Fecha de Ingreso: septiembre-2010
Mensajes: 2
Antigüedad: 13 años, 7 meses
Puntos: 0
Exclamación Impresion en pdf

Buenos dias, cordial saludo.
compañeros estoy realizando un aplicativo en php en la cual imprime formatos selecionando de varias tablas sus registros, ejemplo: en la tabla usuario identificacion, nombre y apellido de la tabla matricula materias, periodo y entre otras....
luego cuando lo llevo a un pantallazo para imprimirlo pero ahora quiero imprimirlo en pdf pero dentro del mismo frame pero solo me aparece los últimos registro de cada tabla seleccionada o de lo contrario no aparcen los registro..
agradecería la colaboracion quien me puede ayudar para convertir un formato en pdf con varias tablas implicadas.
gracias
  #2 (permalink)  
Antiguo 17/09/2010, 10:34
Avatar de carlos_belisario
Colaborador
 
Fecha de Ingreso: abril-2010
Ubicación: Venezuela Maracay Aragua
Mensajes: 3.156
Antigüedad: 14 años
Puntos: 461
Respuesta: Impresion en pdf

ak hay una clase para crear pdf fpdf revisala y espero te ayude
__________________
aprende d tus errores e incrementa tu conocimientos
it's not a bug, it's an undocumented feature By @David
php the right way
  #3 (permalink)  
Antiguo 17/09/2010, 12:30
 
Fecha de Ingreso: septiembre-2010
Mensajes: 2
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: Impresion en pdf

Si ya descarge el archivo FPDF pero al imprimir solo me imprime el ultimo registro
este es el codigo

<?php
session_start();
?>
<?php
session_start();
?>
<?php
require('fpdf/fpdf.php');
require('conexion.php');
class PDF extends FPDF
{
var $widths;
var $aligns;
function SetWidths($w)
{
$this->widths=$w;
}
function SetAligns($a)
{
$this->aligns=$a;
}
function Row($data)
{
$nb=0;
for($i=0;$i<count($data);$i++)
$nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
$h=4*$nb;
$this->CheckPageBreak($h);
for($i=0;$i<count($data);$i++)
{
$w=$this->widths[$i];
$a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
$x=$this->GetX();
$y=$this->GetY();
$this->MultiCell($w,4,$data[$i],0,$a);
$this->SetXY($x+$w,$y);
}
$this->Ln($h);
}
function CheckPageBreak($h)
{
if($this->GetY()+$h>$this->PageBreakTrigger)
$this->AddPage($this->CurOrientation);
}
function NbLines($w,$txt)
{
$cw=&$this->CurrentFont['cw'];
if($w==0)
$w=$this->w-$this->rMargin-$this->x;
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
$s=str_replace("\r",'',$txt);
$nb=strlen($s);
if($nb>0 and $s[$nb-1]=="\n")
$nb--;
$sep=-1;
$i=0;
$j=0;
$l=0;
$nl=1;
while($i<$nb)
{
$c=$s[$i];
if($c=="\n")
{
$i++;
$sep=-1;
$j=$i;
$l=0;
$nl++;
continue;
}
if($c==' ')
$sep=$i;
$l+=$cw[$c];
if($l>$wmax)
{
if($sep==-1)
{
if($i==$j)
$i++;
}
else
$i=$sep+1;
$sep=-1;
$j=$i;
$l=0;
$nl++;
}
else
$i++;
}
return $nl;
}
function Header()
{
//$this->Image('ima_acedemi\LogoAunar.png',015,15,58);
//$this->Image('ima_acedemi\EscuAunar.png',240,15,20);
$this->Ln(05);
$this->SetFont('Arial','B',15);
$this->Cell(115);
$this->Cell(30,10,'AUNAR',0,2,'C');
$this->SetFont('Arial','B',10);
$this->Cell(30,10,'Extension Cali',0,1,'C');
$this->Cell(260,10,'MATRICULA ACADEMICA',1,1,'C');
$this->SetFont('Arial','B',7);
$this->Ln(01);
}
function Footer()
{
$this->SetY(-15);
$this->SetFont('Arial','B',8);
$this->Cell(50,10,'Registro y Control Academico',0,0,'R');
$this->Cell(180);
$this->Cell(20,10,'Page '.$this->PageNo().'',0,0,'L');
}
}
$cosed = $_GET['cosed'];
$copro = $_GET['copro'];
$cod_pl = $_GET['cod_pl'];
$per_mt = $_GET['per_mt'];
$jor_mt = $_GET['jor_mt'];
$ide_e = $_GET['ide_e'];

$pdf=new PDF('L','mm','Letter');
$pdf->Open();
$pdf->AddPage();
$pdf->Cell(30,9,$cosed,1,0,'C');
$pdf->Cell(30,9,$copro,1,0,'C');
$pdf->Cell(30,9,$cod_pl,1,0,'C');
$pdf->Cell(30,9,$per_mt,1,0,'C');
$pdf->Cell(30,9,$jor_mt,1,0,'C');
$pdf->Cell(30,9,$ide_e,1,1,'C');

$con = new DB;
$matricula = $con->conectar();
$strConsulta = "SELECT * from programa
where cod_pro = '$copro'";
$matricula = mysql_query($strConsulta);
$numfilas = mysql_num_rows($matricula);
$fila = mysql_fetch_array($matricula);
$nopro = $fila[1];
$tipro = $fila[2];
$pdf->Cell(30,9,$copro,1,0,'C');
$pdf->Cell(30,9,$nopro,1,0,'C');
$pdf->Cell(30,9,$tipro,1,0,'C');
$pdf->Cell(30,9,$numfilas,1,0,'C');

$pdf->SetMargins(10,10,10,20,10,10,10);
$pdf->SetFont('Arial','B',8);
$pdf->SetWidths(array(20, 20, 70, 20, 20, 20, 20));

for ($i=0; $i<$numfilas; $i++)
{
$busca ="select nom_mat,sem_mat,tip_mat,not_mat,cre_mat
from materia";
$eje1 = mysql_query($busca);
$nrow1 = mysql_num_rows($eje1);
$sem_m = $nrow1['sem_mat'];
$nom_m = $nrow1['nom_mat'];
$tip_m = $nrow1['tip_mat'];
$not_m = $nrow1['not_mat'];
$cre_m = $nrow1['cre_mat'];
$pdf->Cell(20,9,$sem_m,1,0,'C');
$pdf->Cell(20,9,$cod_m[$i],1,0,'C');
$pdf->Cell(20,9,$nom_m,1,0,'C');
$pdf->Cell(20,9,$jor_m[$i],1,0,'C');
$pdf->Cell(20,9,$tip_m,1,0,'C');
$pdf->Cell(20,9,$not_m,1,0,'C');
$pdf->Cell(20,9,$cre_m,1,0,'C');
$pdf->Ln();
}
$pdf->Output();
?>

Etiquetas: impresion, pdf
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 21:41.