Tema: Pdf y php
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 22/05/2013, 07:42
Avatar de evolutionrgm
evolutionrgm
 
Fecha de Ingreso: mayo-2011
Mensajes: 108
Antigüedad: 13 años
Puntos: 5
Respuesta: Pdf y php

Estimado

Utiliza esto para pasar de php a pdf utiliza la clase class.ezpdf la cual puedes descargar desde aca http://pubsvn.ez.no/doxygen/4.0/html/files.html.

ahora vamos al codigo supongo que ya tienes tu bd y ya haz generado tus ingresos y quieres mostrar los datos este codigo lo extraigo de la siguiente web http://blog.unijimpe.net/generar-pdf-con-php-y-mysql/ . lo busque por google como php + pdf . :)

Código PHP:
Ver original
  1. <?php
  2. require_once('class.ezpdf.php');
  3. $pdf =& new Cezpdf('a4');
  4. $pdf->selectFont('../fonts/courier.afm');
  5. $pdf->ezSetCmMargins(1,1,1.5,1.5);
  6.  
  7. $conexion = mysql_connect("internal-db.s10556.gridserver.com", "db10556", "XU7kmnPw");
  8. mysql_select_db("db10556_unijimpe_demo", $conexion);
  9. $queEmp = "SELECT nombre, direccion, telefono FROM empresa ORDER BY nombre ASC";
  10. $resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
  11. $totEmp = mysql_num_rows($resEmp);
  12.  
  13. $ixx = 0;
  14. while($datatmp = mysql_fetch_assoc($resEmp)) {
  15.     $ixx = $ixx+1;
  16.     $data[] = array_merge($datatmp, array('num'=>$ixx));
  17. }
  18. $titles = array(
  19.                 'num'=>'<b>Num</b>',
  20.                 'nombre'=>'<b>Empresa</b>',
  21.                 'direccion'=>'<b>Direccion</b>',
  22.                 'telefono'=>'<b>Telefono</b>'
  23.             );
  24. $options = array(
  25.                 'shadeCol'=>array(0.9,0.9,0.9),
  26.                 'xOrientation'=>'center',
  27.                 'width'=>500
  28.             );
  29. $txttit = "<b>BLOG.UNIJIMPE.NET</b>\n";
  30. $txttit.= "Ejemplo de PDF con PHP y MYSQL \n";
  31.  
  32. $pdf->ezText($txttit, 12);
  33. $pdf->ezTable($data, $titles, '', $options);
  34. $pdf->ezText("\n\n\n", 10);
  35. $pdf->ezText("<b>Fecha:</b> ".date("d/m/Y"), 10);
  36. $pdf->ezText("<b>Hora:</b> ".date("H:i:s")."\n\n", 10);
  37. $pdf->ezStream();
  38.  $pdf->Output();
  39. ?>