Respuesta: Ayuda con fpdf Bueno diran que tonto soy, pero ya resolvi yo solo el problema con este escript, por si a alguien le sirve
comunes.php Código PHP: <? class PDF extends FPDF { //Cabecera de pgina function Header() { //Logo $this->Image('../imagenes/logo.png',320,5,30); } //Pie de pgina function Footer() { $fecha=date("d-m-Y"); $this->SetFont('Arial','',6); $this->SetY(-17); $this->Cell(0,10,'Escuela Miguel Hidalgo',0,0,'C'); $this->SetY(-14); $this->Cell(0,10,html_entity_decode('Cerrada de Juárez N° 327. Colonia Centro, Macuspana, Tabasco, México.'.$fecha),0,0,'C'); $this->SetY(-11); $this->Cell(0,10,html_entity_decode('(936) 362-04-65'),0,0,'C'); $this->SetY(-8); $this->Cell(0,10,'Pagina '.$this->PageNo().'',0,0,'C'); } /** Aqui **/ var $widths; var $aligns; function SetWidths($w) { //Set the array of column widths $this->widths=$w; } function SetAligns($a) { //Set the array of column alignments $this->aligns=$a; } function Row($data) { //Calculate the height of the row $nb=0; for($i=0;$i<count($data);$i++) $nb=max($nb,$this->NbLines($this->widths[$i],$data[$i])); $h=5*$nb; //Issue a page break first if needed $this->CheckPageBreak($h); //Draw the cells of the row for($i=0;$i<count($data);$i++) { $w=$this->widths[$i]; $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'J'; //Save the current position $x=$this->GetX(); $y=$this->GetY(); //Draw the border $this->Rect($x,$y,$w,$h); //Print the text $this->MultiCell($w,5,$data[$i],0,$a); //Put the position to the right of the cell $this->SetXY($x+$w,$y); } //Go to the next line $this->Ln($h); } function CheckPageBreak($h) { //If the height h would cause an overflow, add a new page immediately if($this->GetY()+$h>$this->PageBreakTrigger) $this->AddPage($this->CurOrientation); } function NbLines($w,$txt) { //Computes the number of lines a MultiCell of width w will take $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; } } ?> ejemplo.php Código PHP: <?php define('FPDF_FONTPATH','font/'); include("fpdf.php"); include("comunes.php"); include("../clases/Cargar_clases.php"); $libros=new Libro(); $rs=$libros->consultar("WHERE libros.id_autor=autores.id_autor AND libros.id_libros_seccion=libros_seccion.id_libros_seccion AND libros.id_editorial=editoriales.id_editorial ORDER BY libros.id_libro"); $rse2=$libros->suma_libros("ORDER BY id_libro"); $row2=$rse2->fetch_assoc(); $total_libros=$row2["total"]; $pdf=new PDF('L','mm','Legal'); $pdf->AddPage(); $pdf->SetMargins(2.5,40); $pdf->SetFont('Arial','B',16); $pdf->SetFillColor(220, 220, 220); $pdf->Text(140,20,"LISTA GENERAL DE LIBROS"); $pdf->SetFont('Arial','',8); $pdf->Ln(30); $pdf->SetLineWidth(.2); $pdf->SetFont('Arial','B',8); $pdf->cell(23,5,'CLAVE',1,0,C); $pdf->cell(95,5,'TITULO',1,0,C); $pdf->cell(60,5,'AUTOR',1,0,C); $pdf->cell(45,5,'EDITORIAL',1,0,C); $pdf->cell(45,5,'SECCIÓN',1,0,C); $pdf->cell(20,5,'EDICIÓN',1,0,C); $pdf->cell(20,5,'ALTA',1,0,C); $pdf->cell(15,5,'ORIGINAL',1,0,C); $pdf->cell(15,5,'COPIA',1,0,C); $pdf->cell(12,5,'TOTAL',1,0,C); $pdf->Ln(); $pdf->SetWidths(array(23,95,60,45,45,20,20,15,15,12)); while($row1=$rs->fetch_assoc()){ $clave=$row1["id_libro"]; $nombre=$row1["nombre"]; $autor=$row1["nombre_autor"]." ".$row1["apellidos"]; $editorial=$row1["editorial"]; $seccion=$row1["seccion"]; $ano_edicion=$row1["ano_edicion"]; $fecha_alta=$row1["fecha_alta"]; $original=$row1["original"]; $copia=$row1["copia"]; $rst=$libros->suma_libros("WHERE id_libro='$clave'"); $row2=$rst->fetch_assoc(); $suma=$row2["total"]; $pdf->Row(array($clave,$nombre,$autor,$editorial,$seccion,$ano_edicion,$fecha_alta,$original,$copia,$suma)); } $pdf->Cell(338,5,"TOTAL DE LIBROS",1,0,"R"); $pdf->Cell(12,5,$total_libros,1,0,"C",0); $pdf->Output("Lista_General_De_Libros_Biblioteca.pdf","D"); ?> |